edu.cornell.cs.sam.core
Interface HeapAllocator

All Known Implementing Classes:
ExplicitFreeAllocator

public interface HeapAllocator

The HeapAllocator manages the SaM heap


Nested Class Summary
static class HeapAllocator.Allocation
          Represents a heap allocation
 
Method Summary
 void free(int pos)
          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 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
 

Method Detail

init

void init()
Resets any internal state in the heap allocator to initial state.

Throws:
SystemException - if there is an error accessing memory

malloc

void malloc(int size)
            throws SystemException
Allocates the specified amount of memory on the heap, and pushes its address on the stack.

Parameters:
size - the amount of memory to allocate
Throws:
SystemException - if there is an error allocating memory

free

void free(int pos)
          throws SystemException
Frees the given position in memory, which must have been allocated with malloc()

Throws:
SystemException - if there is an error freeing memory

setMemory

void setMemory(Memory mem)
Sets the memory object of this allocator

Parameters:
mem - the memory

getMemory

Memory getMemory()
Gets the memory object of this allocator

Returns:
The memory object

getAllocations

java.util.Iterator<HeapAllocator.Allocation> getAllocations()
Gets an iterator to the allocations on the heap

Returns:
an allocation iterator