New function heapblocksize()
git-svn-id: svn://svn.cc65.org/cc65/trunk@3157 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
39
libsrc/common/_heapblocksize.s
Normal file
39
libsrc/common/_heapblocksize.s
Normal file
@@ -0,0 +1,39 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-07-17
|
||||
;
|
||||
; size_t __fastcall__ _heapblocksize (const void* ptr);
|
||||
;
|
||||
; Return the size of an allocated block.
|
||||
;
|
||||
|
||||
.importzp ptr1
|
||||
.export __heapblocksize
|
||||
|
||||
.include "_heap.inc"
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Code
|
||||
|
||||
__heapblocksize:
|
||||
|
||||
; Decrement the block pointer so it points to the admin data
|
||||
|
||||
sec
|
||||
sbc #HEAP_ADMIN_SPACE ; Assume it's less than 256
|
||||
bcs L1
|
||||
dex
|
||||
L1: sta ptr1
|
||||
stx ptr1+1
|
||||
|
||||
; Load the size from the given block
|
||||
|
||||
ldy #1
|
||||
lda (ptr1),y
|
||||
tax
|
||||
dey
|
||||
lda (ptr1),y
|
||||
|
||||
; Done
|
||||
|
||||
rts
|
||||
|
||||
Reference in New Issue
Block a user