edu.cornell.cs.sam.core
Class ExplicitFreeAllocator

java.lang.Object
  extended by edu.cornell.cs.sam.core.ExplicitFreeAllocator
All Implemented Interfaces:
HeapAllocator

public class ExplicitFreeAllocator
extends java.lang.Object
implements HeapAllocator

This allocator provides support for explicit malloc()/free() Expects heap size larger than Memory.UNIT_SIZE


Nested Class Summary
 
Nested classes/interfaces inherited from interface edu.cornell.cs.sam.core.HeapAllocator
HeapAllocator.Allocation
 
Constructor Summary
ExplicitFreeAllocator()
           
 
Method Summary
 void free(int req_addr)
          Frees the given position in memory, which must have been allocated with malloc()
 java.util.Iterator<HeapAllocator.Allocation> getAllocations()
          Gets an iterator to the allocations on the heap
 Memory getMemory()
          Gets the memory object of this allocator
 void init()
          Resets any internal state in the heap allocator to initial state.
 void malloc(int req_size)
          Allocates the specified amount of memory on the heap, and pushes its address on the stack.
 void setMemory(Memory mem)
          Sets the memory object of this allocator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExplicitFreeAllocator

public ExplicitFreeAllocator()
Method Detail

getMemory

public Memory getMemory()
Description copied from interface: HeapAllocator
Gets the memory object of this allocator

Specified by:
getMemory in interface HeapAllocator
Returns:
The memory object

setMemory

public void setMemory(Memory mem)
Description copied from interface: HeapAllocator
Sets the memory object of this allocator

Specified by:
setMemory in interface HeapAllocator
Parameters:
mem - the memory

init

public void init()
Description copied from interface: HeapAllocator
Resets any internal state in the heap allocator to initial state.

Specified by:
init in interface HeapAllocator

malloc

public void malloc(int req_size)
            throws SystemException
Description copied from interface: HeapAllocator
Allocates the specified amount of memory on the heap, and pushes its address on the stack.

Specified by:
malloc in interface HeapAllocator
Parameters:
req_size - the amount of memory to allocate
Throws:
SystemException - if there is an error allocating memory

free

public void free(int req_addr)
          throws SystemException
Description copied from interface: HeapAllocator
Frees the given position in memory, which must have been allocated with malloc()

Specified by:
free in interface HeapAllocator
Throws:
SystemException - if there is an error freeing memory

getAllocations

public java.util.Iterator<HeapAllocator.Allocation> getAllocations()
Description copied from interface: HeapAllocator
Gets an iterator to the allocations on the heap

Specified by:
getAllocations in interface HeapAllocator
Returns:
an allocation iterator