public static global::System.IntPtr Malloc(ulong size, [CallerMemberName] string memberName = "", [CallerFilePath] string fileName = "", [CallerLineNumber] int lineNumber = 0) { CallerInformation caller = new CallerInformation(memberName, fileName, lineNumber); IntPtr __ret = __Internal.JeMalloc(size); if (__ret != IntPtr.Zero) { Allocations.Add(__ret); //AllocationsDetails.Add(new Tuple<IntPtr, ulong, CallerInformation>(__ret, size, caller)); return(__ret); } else { throw new OutOfMemoryException($"Could not allocate {size} bytes for {GetCallerDetails(caller)}."); } }
public static global::System.IntPtr Malloc(ulong size, [CallerMemberName] string memberName = "", [CallerFilePath] string fileName = "", [CallerLineNumber] int lineNumber = 0) { CallerInformation caller = new CallerInformation(memberName, fileName, lineNumber); Initialized = true; IntPtr __ret = __Internal.JeMalloc(size); if (__ret != IntPtr.Zero) { allocLock.EnterWriteLock(); _Allocations.Add(__ret, 0); allocLock.ExitWriteLock(); return(__ret); } else { throw new OutOfMemoryException($"Could not allocate {size} bytes for {GetCallerDetails(caller)}."); } }
internal static string GetCallerDetails(CallerInformation c) { return($"Member {c.Name} at line {c.LineNumber} in file {c.File}"); }