dbghelp: Speed up pool_alloc. Patch by Eric Pouech.
This commit is contained in:
parent
f94127f2ca
commit
a2968c8fab
|
@ -73,19 +73,18 @@ void pool_destroy(struct pool* pool)
|
||||||
|
|
||||||
void* pool_alloc(struct pool* pool, unsigned len)
|
void* pool_alloc(struct pool* pool, unsigned len)
|
||||||
{
|
{
|
||||||
struct pool_arena** parena;
|
|
||||||
struct pool_arena* arena;
|
struct pool_arena* arena;
|
||||||
void* ret;
|
void* ret;
|
||||||
|
|
||||||
len = (len + 3) & ~3; /* round up size on DWORD boundary */
|
len = (len + 3) & ~3; /* round up size on DWORD boundary */
|
||||||
assert(sizeof(struct pool_arena) + len <= pool->arena_size && len);
|
assert(sizeof(struct pool_arena) + len <= pool->arena_size && len);
|
||||||
|
|
||||||
for (parena = &pool->first; *parena; parena = &(*parena)->next)
|
for (arena = pool->first; arena; arena = arena->next)
|
||||||
{
|
{
|
||||||
if ((char*)(*parena) + pool->arena_size - (*parena)->current >= len)
|
if ((char*)arena + pool->arena_size - arena->current >= len)
|
||||||
{
|
{
|
||||||
ret = (*parena)->current;
|
ret = arena->current;
|
||||||
(*parena)->current += len;
|
arena->current += len;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,10 +92,9 @@ void* pool_alloc(struct pool* pool, unsigned len)
|
||||||
arena = HeapAlloc(GetProcessHeap(), 0, pool->arena_size);
|
arena = HeapAlloc(GetProcessHeap(), 0, pool->arena_size);
|
||||||
if (!arena) {FIXME("OOM\n");return NULL;}
|
if (!arena) {FIXME("OOM\n");return NULL;}
|
||||||
|
|
||||||
*parena = arena;
|
|
||||||
|
|
||||||
ret = (char*)arena + sizeof(*arena);
|
ret = (char*)arena + sizeof(*arena);
|
||||||
arena->next = NULL;
|
arena->next = pool->first;
|
||||||
|
pool->first = arena;
|
||||||
arena->current = (char*)ret + len;
|
arena->current = (char*)ret + len;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue