/// <summary> /// Allocate a memory at the highest address. /// </summary> /// <param name="size"> the size of the memory to be allocated </param> /// <param name="addrAlignment"> base address alignment of the requested block </param> /// <returns> the base address of the allocated memory /// 0 if the memory could not be allocated </returns> public virtual int allocHigh(int size, int addrAlignment) { for (MemoryChunk memoryChunk = high; memoryChunk != null; memoryChunk = memoryChunk.previous) { if (memoryChunk.isAvailable(size, addrAlignment)) { return(allocHigh(memoryChunk, size, addrAlignment)); } } return(0); }
/// <summary> /// Allocate a memory at the lowest address. /// </summary> /// <param name="size"> the size of the memory to be allocated </param> /// <param name="addrAlignment"> base address alignment of the requested block </param> /// <returns> the base address of the allocated memory, /// 0 if the memory could not be allocated </returns> public virtual int allocLow(int size, int addrAlignment) { for (MemoryChunk memoryChunk = low; memoryChunk != null; memoryChunk = memoryChunk.next) { if (memoryChunk.isAvailable(size, addrAlignment)) { return(allocLow(memoryChunk, size, addrAlignment)); } } return(0); }