Commit 18ee50e5 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Fixed handling block_cnt in jsheap_alloc.

parent a2ca4812
......@@ -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)
return NULL;
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment