Fixed an error in calloc reported by Marc 'BlackJack' Rintsch.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5932 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2012-11-12 23:07:02 +00:00
parent f03d5c54d8
commit e04f1d8cb0

View file

@ -7,8 +7,8 @@
; ;
.export _calloc .export _calloc
.import _malloc, _memset .import _malloc, __bzero
.import tosumulax, pushax, push0 .import tosumulax, pushax
; ------------------------------------------------------------------------- ; -------------------------------------------------------------------------
@ -35,21 +35,20 @@
cpx #0 cpx #0
bne ClearBlock bne ClearBlock
cmp #0 cmp #0
beq ClearBlock bne ClearBlock
; We have a NULL pointer, bail out ; We have a NULL pointer, bail out
rts rts
; No NULL pointer, clear the block. memset will return a pointer to the ; No NULL pointer, clear the block. _bzero will return a pointer to the
; block which is exactly what we want. ; block which is exactly what we want.
ClearBlock: ClearBlock:
jsr pushax ; ptr jsr pushax ; ptr
jsr push0 ; #0
lda Size lda Size
ldx Size+1 ; Size ldx Size+1 ; Size
jmp _memset jmp __bzero
.endproc .endproc