public void NativeFree(IntPtr nat) { if (nat != IntPtr.Zero) { MemoryNative.Free(nat); } }
protected virtual void Dispose(bool disposing) { if (!Disposed && ShouldFree) { MemoryNative.Free(this.Handle); } Disposed = true; }
public IntPtr ManagedToNativeAlloc(T man) { GCHandle pinnedData = GCHandle.Alloc(man, GCHandleType.Pinned); IntPtr ptr = pinnedData.AddrOfPinnedObject(); IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf <T>()); pinnedData.Free(); return(nat); }
public IntPtr ManagedToNativeAllocInlistNode(T man) { var node = new InlistNode <IntPtr>(); node.Val = ManagedToNativeAlloc(man); GCHandle pinnedData = GCHandle.Alloc(node, GCHandleType.Pinned); IntPtr ptr = pinnedData.AddrOfPinnedObject(); IntPtr nat = MemoryNative.AllocCopy(ptr, Marshal.SizeOf <InlistNode <IntPtr> >()); pinnedData.Free(); return(nat); }
public void NativeFreeInlistNode(IntPtr nat, bool freeElement) { if (nat == IntPtr.Zero) { return; } if (freeElement) { NativeFreeInlistNodeElement(nat); } MemoryNative.Free(nat); }
public static IntPtr ManagedStringToNativeUtf8Alloc(string managedString) { if (managedString == null) { return(IntPtr.Zero); } byte[] strbuf = Encoding.UTF8.GetBytes(managedString); IntPtr native = MemoryNative.Alloc(strbuf.Length + 1); Marshal.Copy(strbuf, 0, native, strbuf.Length); Marshal.WriteByte(native + strbuf.Length, 0); // write the terminating null return(native); }
/// <summary>Returns an enumerator that iterates throught this accessor.</summary> public IEnumerator <T> GetEnumerator() { if (Handle == IntPtr.Zero) { throw new ObjectDisposedException(base.GetType().Name); } IntPtr tmp = MemoryNative.Alloc(Marshal.SizeOf(typeof(IntPtr))); uint position = 0; try { while (eina_accessor_data_get(Handle, position, tmp)) { IntPtr data = (IntPtr)Marshal.PtrToStructure(tmp, typeof(IntPtr)); yield return(Convert(data)); position += 1; } } finally { MemoryNative.Free(tmp); } }
public IntPtr ManagedToNativeAlloc(T man) { return(MemoryNative.StrDup((string)(object)man)); }
public IntPtr EinaFreeCb() { return(MemoryNative.FreeFuncPtrGet()); }
public void NativeFreeInlistNode(IntPtr nat, bool freeElement) { MemoryNative.Free(nat); }
public void NativeFree(IntPtr nat) { MemoryNative.Free(nat); }
public IntPtr EinaFreeCb() { return(MemoryNative.EflUnrefFuncPtrGet()); }
public IntPtr EinaCompareCb() { return(MemoryNative.PtrCompareFuncPtrGet()); }
public void NativeFreeInplace(IntPtr nat) { MemoryNative.FreeRef(nat); }