/// <summary>Allocates from unmanaged memory sufficient memory to hold an object of type T.</summary> /// <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>(in T value = default) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, new HGlobalMemoryMethods().AllocMem, out int s), s);
/// <summary>Allocates from unmanaged memory sufficient memory to hold an object of type T.</summary> /// <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(T)) => new SafeHGlobalHandle(InteropExtensions.StructureToPtr(value, mm.AllocMem, out int s), s);