diff options
author | chatty | 1992-12-15 10:55:33 +0000 |
---|---|---|
committer | chatty | 1992-12-15 10:55:33 +0000 |
commit | 3a4838bed13b767132cbdf06364b2658da6cc356 (patch) | |
tree | f6d7b33264c4634d069409ba3169126823ac4090 /utils/Allocator.h | |
parent | 23abb4b87c7e40ed259dd02f653516f60e55ade4 (diff) | |
download | ivy-league-3a4838bed13b767132cbdf06364b2658da6cc356.zip ivy-league-3a4838bed13b767132cbdf06364b2658da6cc356.tar.gz ivy-league-3a4838bed13b767132cbdf06364b2658da6cc356.tar.bz2 ivy-league-3a4838bed13b767132cbdf06364b2658da6cc356.tar.xz |
Initial revision
Diffstat (limited to 'utils/Allocator.h')
-rw-r--r-- | utils/Allocator.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/utils/Allocator.h b/utils/Allocator.h new file mode 100644 index 0000000..33939f7 --- /dev/null +++ b/utils/Allocator.h @@ -0,0 +1,46 @@ +/* + * CENA C++ Utilities + * + * by Stephane Chatty + * + * Copyright 1992 + * Centre d'Etudes de la Navigation Aerienne (CENA) + * + * Memory allocation (original C version by Michel Beaudouin-Lafon) + * + * $Id$ + * $CurLog$ + */ + + +#ifndef Allocator_H_ +#define Allocator_H_ + +#include "cplus_bugs.h" + +class CcuAllocator { +private: +static void MemoryOverflow (); + + unsigned int BlockSize; + unsigned int ChunkSize; + void* FreeList; /* list of free blocks of memory */ + void* AllocEnd; /* end of the last chunk */ + void* AllocNext; /* room left in the last chunk */ + +public: + CcuAllocator (unsigned int); + ~CcuAllocator (); + void* Alloc (); + void Free (void*); +}; + +#ifndef CPLUS_BUG19 +template <class OBJECT> class CcuAllocatorOf : public CcuAllocator { +public: +inline CcuAllocatorOf () : CcuAllocator (sizeof (OBJECT)) {} +inline OBJECT* Alloc () { return (OBJECT*) CcuAllocator::Alloc (); } +}; +#endif + +#endif /* Allocator_H_ */ |