public static IntPtr AllocHGlobal(int cb) { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150503/udp var p = new CMalloc(cb); return (IntPtr)p; }
public static CMalloc Of(string e) { CMalloc x = new CMalloc(e.Length + 1); x.setString(0, e); return(x); }
public void free() { if (peer != 0) { CMalloc.free(peer); peer = 0; } }
public CPtr OfBytes(params sbyte[] e) { CMalloc c = CMalloc.Of(e); Add(c); return(c); }
public CMalloc OfString(string p) { CMalloc c = CMalloc.Of(p); Add(c); return(c); }
public CMalloc OfBytes(params int[] e) { CMalloc c = CMalloc.Of(Convert.ToByteArray(e)); Add(c); return(c); }
/// <summary> /// allocates jint and sets it /// </summary> /// <param name="p"></param> /// <returns></returns> public CMalloc OfInt32(int p) { CMalloc c = CMalloc.Of(p); Add(c); return(c); }
/// <summary> /// allocates jint and sets it /// </summary> /// <param name="e"></param> /// <returns></returns> public static CMalloc Of(int e) { CMalloc x = new CMalloc(CMalloc.sizeof_jint()); x.setInt(0, e); return(x); }
public CMalloc OfInt64(long p) { CMalloc c = new CMalloc(jni.CMalloc.sizeof_jlong()); c.setLong(0, p); Add(c); return(c); }
public void Add(CMalloc m) { if (IsVerbose) { global::System.Console.WriteLine("memc: " + Size + " bytes + " + m.Size + " bytes at 0x" + m.Pointer.ToString("x8") ); } list.add(m); }
public static CMalloc Of(params sbyte[] e) { CMalloc x = new CMalloc(e.Length); for (int i = 0; i < e.Length; i++) { x.setByte(i, e[i]); } return(x); }
public CMalloc OfSize(int mb) { CMalloc m = new CMalloc(mb); for (int i = 0; i < mb; i++) { m.setByte(i, 0); } Add(m); return(m); }
// https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150503/udp // X:\jsc.svn\examples\java\hybrid\JVMCLRLoadLibrary\JVMCLRLoadLibrary\Program.cs public static IntPtr StringToHGlobalAnsi(string s) { if (s == null) { return (IntPtr)CPtr.NULL; } var bytes = (sbyte[])(object)Encoding.ASCII.GetBytes(s); var p = new CMalloc(bytes.Length + 1); p.copyIn(0, bytes, 0, bytes.Length); return (IntPtr)p; }
public void Collect() { if (IsVerbose) { global::System.Console.WriteLine("memc: " + Size + " bytes"); } while (list.size() > 0) { CMalloc m = (CMalloc)list.get(0); m.free(); list.remove(0); } if (IsVerbose) { global::System.Console.WriteLine("memc: " + Size + " bytes"); } }
public static CMalloc Of(params sbyte[] e) { CMalloc x = new CMalloc(e.Length); for (int i = 0; i < e.Length; i++) { x.setByte(i, e[i]); } return x; }
/// <summary> /// allocates jint and sets it /// </summary> /// <param name="e"></param> /// <returns></returns> public static CMalloc Of(int e) { CMalloc x = new CMalloc(CMalloc.sizeof_jint()); x.setInt(0, e); return x; }
public static CMalloc Of(string e) { CMalloc x = new CMalloc(e.Length + 1); x.setString(0, e); return x; }
public CMalloc OfInt64(long p) { CMalloc c = new CMalloc(jni.CMalloc.sizeof_jlong()); c.setLong(0, p); Add(c); return c; }
public CMalloc OfSize(int mb) { CMalloc m = new CMalloc(mb); for (int i = 0; i < mb; i++) { m.setByte(i, 0); } Add(m); return m; }
public CMalloc OfHexString(string p) { return(CMalloc.Of(Convert.FromHexString(p))); }