diff --git a/Core/Extensions/InteropExtensions.cs b/Core/Extensions/InteropExtensions.cs
index d96cf05d..04a33674 100644
--- a/Core/Extensions/InteropExtensions.cs
+++ b/Core/Extensions/InteropExtensions.cs
@@ -173,7 +173,7 @@ namespace Vanara.Extensions
if (count == 0)
{
var ret = memAlloc(bytesAllocated);
- Marshal.Copy(new byte[bytesAllocated], 0, ret, bytesAllocated);
+ ret.FillMemory(0, bytesAllocated);
return ret;
}
@@ -193,7 +193,7 @@ namespace Vanara.Extensions
ms.Position += (count + 1) * IntPtr.Size;
for (var i = 0; i < list.Count; i++)
{
- ms.Poke(list[i] == null ? IntPtr.Zero : ms.Pointer.Offset(ms.Position), prefixBytes + (i * IntPtr.Size));
+ ms.Poke(list[i] is null ? IntPtr.Zero : ms.Pointer.Offset(ms.Position), prefixBytes + (i * IntPtr.Size));
ms.Write(list[i]);
}
ms.Poke(IntPtr.Zero, prefixBytes + (count * IntPtr.Size));
@@ -209,6 +209,74 @@ namespace Vanara.Extensions
}
}
+ ///
+ /// Marshals data from a managed list of objects to an unmanaged block of memory allocated by the method.
+ ///
+ /// The enumerated list of objects to marshal.
+ ///
+ /// The function that allocates the memory for the block of objects (typically or .
+ ///
+ /// The bytes allocated by the method.
+ ///
+ /// if set to the pointer will be processed by storing a reference to the value; if ,
+ /// the pointer value will be directly inserted into the array of pointers.
+ ///
+ /// The character set to use for strings.
+ /// Number of bytes preceding the allocated objects.
+ /// Pointer to the allocated native (unmanaged) array of objects stored using the character set defined by .
+ public static IntPtr MarshalObjectsToPtr(this IEnumerable