fix new/delete mismatch in slow_allocator, also use that for lazy_allocator

This commit is contained in:
gbeauche 2006-01-28 21:59:41 +00:00
parent 022d09375f
commit e0589a097e

View File

@ -32,7 +32,7 @@ template< class data >
struct slow_allocator struct slow_allocator
{ {
data * acquire() const { return new data; } data * acquire() const { return new data; }
void release(data * const x) const { free(x); } void release(data * const x) const { delete x; }
}; };
/** /**
@ -77,7 +77,7 @@ lazy_allocator<data>::~lazy_allocator()
while (p) { while (p) {
pool * d = p; pool * d = p;
p = p->next; p = p->next;
free(d); delete d;
} }
} }
@ -87,7 +87,7 @@ data * lazy_allocator<data>::acquire()
if (!chunks) { if (!chunks) {
// There is no chunk left, allocate a new pool and link the // There is no chunk left, allocate a new pool and link the
// chunks into the free list // chunks into the free list
pool * p = (pool *)malloc(sizeof(pool)); pool * p = new pool;
for (chunk * c = &p->chunks[0]; c < &p->chunks[pool_count]; c++) { for (chunk * c = &p->chunks[0]; c < &p->chunks[pool_count]; c++) {
c->next = chunks; c->next = chunks;
chunks = c; chunks = c;