예제 #1
0
        private void op_malloc(uint[] args)
        {
            uint size = args[0];
            if ((int)size <= 0)
            {
                args[1] = 0;
                return;
            }

            if (heap == null)
            {
                uint oldEndMem = image.EndMem;
                heap = new HeapAllocator(oldEndMem, HandleHeapMemoryRequest);
                heap.MaxSize = maxHeapSize;
                args[1] = heap.Alloc(size);
                if (args[1] == 0)
                {
                    heap = null;
                    image.EndMem = oldEndMem;
                }
            }
            else
            {
                args[1] = heap.Alloc(size);
            }
        }