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;
        }
Beispiel #2
0
        public static CMalloc Of(string e)
        {
            CMalloc x = new CMalloc(e.Length + 1);

            x.setString(0, e);

            return(x);
        }
Beispiel #3
0
 public void free()
 {
     if (peer != 0)
     {
         CMalloc.free(peer);
         peer = 0;
     }
 }
Beispiel #4
0
            public CPtr OfBytes(params sbyte[] e)
            {
                CMalloc c = CMalloc.Of(e);

                Add(c);

                return(c);
            }
Beispiel #5
0
            public CMalloc OfString(string p)
            {
                CMalloc c = CMalloc.Of(p);

                Add(c);

                return(c);
            }
Beispiel #6
0
            public CMalloc OfBytes(params int[] e)
            {
                CMalloc c = CMalloc.Of(Convert.ToByteArray(e));

                Add(c);

                return(c);
            }
Beispiel #7
0
            /// <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);
            }
Beispiel #8
0
        /// <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);
        }
Beispiel #9
0
            public CMalloc OfInt64(long p)
            {
                CMalloc c = new CMalloc(jni.CMalloc.sizeof_jlong());

                c.setLong(0, p);

                Add(c);

                return(c);
            }
Beispiel #10
0
            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);
            }
Beispiel #11
0
        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);
        }
Beispiel #12
0
            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);
            }
Beispiel #13
0
        // 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;
        }
Beispiel #14
0
            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 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);
            }
Beispiel #21
0
 public CMalloc OfHexString(string p)
 {
     return(CMalloc.Of(Convert.FromHexString(p)));
 }