CurtHagenlocher commented on issue #99:
URL: https://github.com/apache/arrow-dotnet/issues/99#issuecomment-4100307262
Can also use the following on older .NET:
```
internal static class AlignedMalloc
{
// Allocate aligned memory
[DllImport("ucrtbase.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _aligned_malloc(
UIntPtr size,
UIntPtr alignment);
// Free aligned memory
[DllImport("ucrtbase.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern void _aligned_free(
IntPtr memblock);
// Optional: reallocate aligned memory
[DllImport("ucrtbase.dll", CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr _aligned_realloc(
IntPtr memblock,
UIntPtr size,
UIntPtr alignment);
[DllImport("kernel32.dll", SetLastError = true, CharSet =
CharSet.Unicode)]
static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("kernel32.dll", SetLastError = true)]
static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
public static bool HasAlignedMalloc()
{
IntPtr h = LoadLibrary("ucrtbase.dll");
if (h == IntPtr.Zero)
return false;
return GetProcAddress(h, "_aligned_malloc") != IntPtr.Zero;
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]