home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
ARASAN_S.ZIP
/
POOL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-31
|
844b
|
42 lines
// Copyright 1994 by Jon Dart. All Rights Reserved.
#ifndef POOL_H
#define POOL_H
#include <stddef.h>
#include "types.h"
class Pool
{
// This class defines a simple memory allocator. Memory is allocated
// in large chunks, and doled out by "new" into smaller chunks. Freed
// memory goes into a free list. Actual deletion of memory doesn't
// occur until freeAll() is called.
public:
Pool(const unsigned chunk_size = 4096);
void *allocate( size_t size );
void free( void *p );
void freeAll(Boolean final = False);
private:
struct chunk;
typedef struct chunk *chunk_ptr;
struct chunk
{
char *mem;
chunk_ptr next;
};
chunk * memChain;
chunk * freeChunks;
char *nextMem;
void *freeChain;
unsigned my_chunk_size;
};
#endif