summaryrefslogtreecommitdiff
path: root/utils/Allocator.h
blob: a93fdfb6d1ed2256264a168134ba275541223067 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 IvlAllocator {
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:
		IvlAllocator (unsigned int);
		~IvlAllocator ();
	void*	Alloc ();
	void	Free (void*);
};

#ifndef CPLUS_BUG19
template <class OBJECT> class IvlAllocatorOf : public IvlAllocator {
public:
inline		IvlAllocatorOf () : IvlAllocator (sizeof (OBJECT))	{}
inline	OBJECT*	Alloc ()	{ return (OBJECT*) IvlAllocator::Alloc (); }
};
#endif

#endif	/* Allocator_H_ */