Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

MemCache Class Reference

#include <MemCache.hpp>

List of all members.

Public Methods

 MemCache (int cachesize)
 MemCache (int *cache, int cachesize)
 use the given memory

 MemCache ()
 ~MemCache ()
int * getMem (int chunksize)
int * getMoreMem (int newsize, int *location, int oldsize)
void freeMem (int *location, int memsize)
void flushMem ()
int * getBegin ()
int * getEnd ()

Private Methods

int * getFromFree (int csize)

Private Attributes

int * begin
int size
 point to the start of our cache

int * end
 the size of our cache

int intsize
 index of where free memory begins

vector< int * > freelist [NLISTS]
 sizeof(int) value

bool ourmem
 array of lists of free memory


Constructor & Destructor Documentation

MemCache::MemCache int    cachesize
 

constructor

Parameters:
cachesize  how much memory to allocate this cache in bytes

MemCache::MemCache int *    cache,
int    cachesize
 

use the given memory

MemCache::MemCache  
 

default constructor that doesn't do much

MemCache::~MemCache  
 

destructor free the memory we allocated


Member Function Documentation

void MemCache::flushMem  
 

reinitializes

void MemCache::freeMem int *    location,
int    memsize
 

"free" the memory at this pointer this cache will remember it in the free list this does not mean delete the memory

Parameters:
location  beginning of location of memory
memsize  how much to free at this location

int * MemCache::getBegin  
 

int * MemCache::getEnd  
 

int * MemCache::getFromFree int    csize [private]
 

returns pointer to memory holes if available returns NULL if nothing is available

Parameters:
int  csize size of memory we're requesting

int * MemCache::getMem int    chunksize
 

Returns:
a pointer to some memory location of size chunksize
Parameters:
chunksize  how much memory we need in bytes as a power of 2,

int * MemCache::getMoreMem int    newsize,
int *    location,
int    oldsize
 

returns pointer to a new location of newsize containing all the elements of the old location

Returns:
NULL if we can't get more memory, or if we are requesting a newsize that is not bigger than the oldsize


Member Data Documentation

int* MemCache::begin [private]
 

int* MemCache::end [private]
 

the size of our cache

vector<int*> MemCache::freelist[NLISTS] [private]
 

sizeof(int) value

int MemCache::intsize [private]
 

index of where free memory begins

bool MemCache::ourmem [private]
 

array of lists of free memory

int MemCache::size [private]
 

point to the start of our cache


The documentation for this class was generated from the following files:
Generated on Fri Feb 6 07:12:04 2004 for LEMUR by doxygen1.2.16