Added PinnedObject implicit operator to unsafe void*.

pull/279/head
dahall 2022-02-05 15:14:55 -07:00
parent 1ae596bd92
commit d29963d39a
1 changed files with 5 additions and 0 deletions

View File

@ -41,6 +41,11 @@ namespace Vanara.InteropServices
/// <returns>The result of the conversion.</returns>
public static implicit operator IntPtr(PinnedObject ap) => !ap.IsInvalid ? ap.pinnedArray.AddrOfPinnedObject().Offset(ap.mOffset) : IntPtr.Zero;
/// <summary>Get an unsafe pointer to the pinned memory of the object with any preset offset.</summary>
/// <param name="ap">The <see cref="PinnedObject"/> instance.</param>
/// <returns>The result of the conversion.</returns>
public static unsafe implicit operator void*(PinnedObject ap) => !ap.IsInvalid ? (void*)ap.pinnedArray.AddrOfPinnedObject().Offset(ap.mOffset) : null;
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
public void Dispose()
{