Changed structure input parameter to CreateFromStructure to 'in' for memory classes

pull/83/head
David Hall 2019-07-27 13:05:10 -06:00
parent d72cca74cb
commit ae0251ded9
4 changed files with 4 additions and 4 deletions

View File

@ -82,7 +82,7 @@ namespace Vanara.InteropServices
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeCoTaskMemHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeCoTaskMemHandle CreateFromStructure<T>(T value = default) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s);
public static SafeCoTaskMemHandle CreateFromStructure<T>(in T value = default) => new SafeCoTaskMemHandle(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the

View File

@ -81,7 +81,7 @@ namespace Vanara.InteropServices
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeHGlobalHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeHGlobalHandle CreateFromStructure<T>(T value = default) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s);
public static SafeHGlobalHandle CreateFromStructure<T>(in T value = default) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s);
/// <summary>
/// Allocates from unmanaged memory to represent a structure with a variable length array at the end and marshal these structure elements. It is the

View File

@ -1527,7 +1527,7 @@ namespace Vanara.PInvoke
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeHeapBlock"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeHeapBlock CreateFromStructure<T>(T value = default) => new SafeHeapBlock(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s);
public static SafeHeapBlock CreateFromStructure<T>(in T value = default) => new SafeHeapBlock(InteropExtensions.StructureToPtr(value, new CoTaskMemoryMethods().AllocMem, out int s), s);
/// <summary>Converts an <see cref="IntPtr"/> to a <see cref="SafeHeapBlock"/> where it owns the reference.</summary>
/// <param name="ptr">The <see cref="IntPtr"/>.</param>

View File

@ -113,7 +113,7 @@ namespace Vanara.InteropServices
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SafeLocalHandle"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SafeLocalHandle CreateFromStructure<T>(T value = default) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, new LocalMemoryMethods().AllocMem, out var s), s);
public static SafeLocalHandle CreateFromStructure<T>(in T value = default) => new SafeLocalHandle(InteropExtensions.StructureToPtr(value, new LocalMemoryMethods().AllocMem, out var s), s);
/// <summary>Converts an <see cref="IntPtr"/> to a <see cref="SafeLocalHandle"/> where it owns the reference.</summary>
/// <param name="ptr">The <see cref="IntPtr"/>.</param>