mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
jscript: Fixed handling block_cnt in jsheap_alloc.
This commit is contained in:
parent
a2ca48127b
commit
18ee50e5d2
@ -83,26 +83,26 @@ void *jsheap_alloc(jsheap_t *heap, DWORD size)
|
|||||||
heap->block_cnt = 1;
|
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;
|
tmp = ((BYTE*)heap->blocks[heap->last_block])+heap->offset;
|
||||||
heap->offset += size;
|
heap->offset += size;
|
||||||
return tmp;
|
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) {
|
if(heap->last_block+1 == heap->block_cnt) {
|
||||||
tmp = heap_realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*));
|
tmp = heap_realloc(heap->blocks, (heap->block_cnt+1)*sizeof(void*));
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
heap->blocks = 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->block_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = heap_alloc(block_size(heap->block_cnt+1));
|
|
||||||
if(!tmp)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
heap->blocks[heap->block_cnt++] = tmp;
|
|
||||||
|
|
||||||
heap->last_block++;
|
heap->last_block++;
|
||||||
heap->offset = size;
|
heap->offset = size;
|
||||||
return heap->blocks[heap->last_block];
|
return heap->blocks[heap->last_block];
|
||||||
|
Loading…
Reference in New Issue
Block a user