Refactor GetResultFullPathName to use char array
https://learn.microsoft.com/en-us/dotnet/framework/interop/default-marshalling-for-strings
https://learn.microsoft.com/en-us/dotnet/standard/native-interop/best-practices#string-parameters
The above Microsoft docs include canonical examples to reduce allocations when marshalling native char arrays into managed code.
This commit should reduce up to 4 allocations per extern call. Which should result in huge savings over the many iterations that Search will generate.
See above commit message. I tested the code and it works, I'm just not familiar enough with C to guarantee that CharSet.Unicode results in native char arrays that are two bytes per char, i.e. proper Utf-16 char that C# expects.
That said, this should be a great reduction in allocations.
With more sleep I realized this PR reduces allocations but now we drastically changed the Search() signature to putting the responsibility on the user for determining how many characters to ask for. In a sense, this is an internal implementation detail yet one that has drastic negative effects if the user doesn't predetermine the length...so it makes sense to accept the PR and change the signature but that's just one opinion.
Ok, we can assume Windows file path length to be max 260, so we use that as the buffer size. I will need to research how Everything handles large path values, otherwise I think this is a sensible first step.