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

            x.setString(0, e);

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

                Add(c);

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

                Add(c);

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

                Add(c);

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

                c.setLong(0, p);

                Add(c);

                return(c);
            }
Example #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);
            }
Example #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);
        }
Example #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);
            }
Example #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;
        }
Example #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");
                }
            }
Example #15
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;
        }
Example #16
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;
        }
Example #17
0
        public static CMalloc Of(string e)
        {
            CMalloc x = new CMalloc(e.Length + 1);

            x.setString(0, e);

            return x;
        }
Example #18
0
            public CMalloc OfInt64(long p)
            {
                CMalloc c = new CMalloc(jni.CMalloc.sizeof_jlong());

                c.setLong(0, p);

                Add(c);

                return c;

            }
Example #19
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;
            }
Example #20
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);
            }
Example #21
0
 public CMalloc OfHexString(string p)
 {
     return(CMalloc.Of(Convert.FromHexString(p)));
 }