36 #ifndef __glubufpool_h_
37 #define __glubufpool_h_
52 Pool(
int,
int,
const char * );
54 inline void* new_buffer(
void );
55 inline void free_buffer(
void * );
63 char *blocklist[NBLOCKS];
70 enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
81 Pool::free_buffer(
void *b )
83 assert( (
this != 0) && (magic == is_allocated) );
87 ((
Buffer *) b)->next = freelist;
98 Pool::new_buffer(
void )
102 assert( (
this != 0) && (magic == is_allocated) );
107 buffer = (
void *) freelist;
108 freelist = freelist->next;
112 nextfree -= buffersize;;
113 buffer = (
void *) (curblock + nextfree);
120 inline void *
operator new( size_t,
Pool & );
121 inline void *
operator new( size_t,
void *);
122 inline void *
operator new(
size_t s)
123 { return ::new
char[s]; }
124 inline void operator delete(
void * ) { assert( 0 ); }
125 inline void operator delete(
void *,
Pool & ) { assert( 0 ); }
126 inline void deleteMe(
Pool & );
130 PooledObj::operator
new( size_t,
Pool& pool )
132 return pool.new_buffer();
136 PooledObj::deleteMe(
Pool& pool )
138 pool.free_buffer( (
void *)
this );