4 ; A resizing, nonshifting heap
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
38 [ :LNOT::DEF:heap__dfn
47 ; Use: Initialises the heap system for use.
51 ; --- heap_useHeap ---
57 ; Use: Registers the resizing heap as the current allocator.
65 ; On exit: R0 == current heap size
66 ; R1 == amount of memory free in the heap
67 ; R2 == size of the largest block free
69 ; Use: Describes the heap's current status.
75 ; On entry: R0 == size of block wanted
77 ; On exit: CC if enough memory was found and
78 ; R0 == pointer to the block allocated
82 ; Use: Allocates a block of at least a given size from a heap. If
83 ; the heap is not big enough, more is claimed from the
90 ; On entry: R0 == pointer to a block created with heap_alloc
94 ; Use: Frees a block allocated using heap_alloc. It tries to
95 ; shrink the heap as much as possible afterwards.
99 ; --- heap_reAlloc ---
101 ; On entry: R0 == pointer to block whose size we want to change
102 ; R1 == the new size of the block
104 ; On exit: CC if block was resized, and
105 ; R0 == pointer to the block (which may have moved)
109 ; Use: Changes the size of a heap block. If possible, the block's
110 ; position is unchanged, but this may not always be the case.
112 ; Note that changing a block's size to 0 is permitted.
118 ;----- That's all, folks ----------------------------------------------------