Skip to content

Need help to choose between friendly and unsafe overloads #1094

Closed Answered by AArnott
netcorefan1 asked this question in Q&A
Discussion options

You must be logged in to vote

Do you see anything wrong with the code?

I'm afraid I don't have time or expertise in particular win32 functions to adequately review your code. Sorry.

public unsafe delegate bool SearchQueryDelegate(ReadOnlySpan<char> state, SYSTEM_PROCESS_INFORMATION* processInfo);

Pheraps I should find a way to remove unsafe from the delegate in order to reduce the unsafe context, but I'm wondering how and if this could cause allocations.

You can sometimes avoid the unsafe keyword by changing the second parameter from a pointer to a ref struct. In this case that would look like ref SYSTEM_PROCESS_INFORMATION. Depending on whether the data is already initialized, in or out may be more appropriate pa…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@netcorefan1
Comment options

@AArnott
Comment options

Answer selected by netcorefan1
Comment options

You must be logged in to vote
1 reply
@AArnott
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1093 on December 12, 2023 22:50.