Preserve LIFO allocation when freeing from the middle of a pool (256642, r=shaver).

This commit is contained in:
brendan%mozilla.org 2004-08-28 18:43:50 +00:00
Родитель 22240334dc
Коммит 4c6759b04f
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -404,11 +404,13 @@ JS_ArenaFreeAllocation(JSArenaPool *pool, void *p, size_t size)
/*
* At this point, a is doomed, so ensure that pool->current doesn't point
* at it. What's more, force future allocations to scavenge all arenas on
* pool, in case some have free space.
* at it. We must preserve LIFO order of mark/release cursors, so we use
* the oversized-allocation arena's back pointer (or if not oversized, we
* use the result of searching the entire pool) to compute the address of
* the arena that precedes a.
*/
if (pool->current == a)
pool->current = &pool->first;
pool->current = (JSArena *) ((char *)ap - offsetof(JSArena, next));
/*
* This is a non-LIFO deallocation, so take care to fix up a->next's back