mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-10-14 02:24:02 +00:00
fix new/delete mismatch in slow_allocator, also use that for lazy_allocator
This commit is contained in:
parent
022d09375f
commit
e0589a097e
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user