mirror of
https://github.com/cc65/cc65.git
synced 2025-01-15 07:31:32 +00:00
Have _heapmaxavail() work as advertised.
The cc65 doc explicitly states that the return value of _heapmaxavail() can be used as parameter of malloc(). To actually allow for that the size of HEAP_ADMIN_SPACE has to be substracted from the raw size of the largest free heap block.
This commit is contained in:
parent
4b085f193e
commit
d001a6f1a0
@ -61,7 +61,7 @@ __heapmaxavail:
|
|||||||
|
|
||||||
; F = F->next;
|
; F = F->next;
|
||||||
|
|
||||||
@L2: iny ; Points to F->next
|
@L2: iny ; Points to F->next
|
||||||
lda (ptr1),y
|
lda (ptr1),y
|
||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
@ -69,8 +69,17 @@ __heapmaxavail:
|
|||||||
stx ptr1
|
stx ptr1
|
||||||
jmp @L1
|
jmp @L1
|
||||||
|
|
||||||
; return Size;
|
; if (Size < HEAP_ADMIN_SPACE) return 0;
|
||||||
|
|
||||||
@L3: lda ptr2
|
@L3: lda ptr2
|
||||||
|
sub #HEAP_ADMIN_SPACE
|
||||||
ldx ptr2+1
|
ldx ptr2+1
|
||||||
|
bcs @L5
|
||||||
|
bne @L4
|
||||||
|
txa
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
; return Size - HEAP_ADMIN_SPACE;
|
||||||
|
|
||||||
|
@L4: dex
|
||||||
|
@L5: rts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user