jscript: Fixed handling block_cnt in jsheap_alloc.

This commit is contained in:
Jacek Caban 2009-02-25 01:28:49 +01:00 committed by Alexandre Julliard
parent a2ca48127b
commit 18ee50e5d2

View File

@ -83,25 +83,25 @@ void *jsheap_alloc(jsheap_t *heap, DWORD size)
heap->block_cnt = 1;
}
if(heap->offset + size < block_size(heap->last_block)) {
if(heap->offset + size <= block_size(heap->last_block)) {
tmp = ((BYTE*)heap->blocks[heap->last_block])+heap->offset;
heap->offset += size;
return tmp;
}
if(size < block_size(heap->last_block+1)) {
if(size <= block_size(heap->last_block+1)) {
if(heap->last_block+1 == heap->block_cnt) {
tmp = heap_realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*));
if(!tmp)
return NULL;
heap->blocks = tmp;
}
tmp = heap_alloc(block_size(heap->block_cnt+1));
if(!tmp)
heap->blocks = tmp;
heap->blocks[heap->block_cnt] = heap_alloc(block_size(heap->block_cnt));
if(!heap->blocks[heap->block_cnt])
return NULL;
heap->blocks[heap->block_cnt++] = tmp;
heap->block_cnt++;
}
heap->last_block++;
heap->offset = size;