@@ -26,7 +26,7 @@ typedef struct {
26
26
} Heap ;
27
27
28
28
static Heap * heap = NULL ;
29
- static void * heap_limit = NULL ;
29
+ static const void * heap_limit = NULL ;
30
30
static size_t heap_split_thresh ;
31
31
static size_t heap_alignment ;
32
32
static size_t heap_max_blocks ;
@@ -123,7 +123,7 @@ bool ta_init(const void *base, const void *limit, const size_t heap_blocks, cons
123
123
heap -> used = NULL ;
124
124
heap -> fresh = heap -> blocks ;
125
125
heap -> top = (size_t )base + sizeof (Heap ) + heap_blocks * sizeof (Block );
126
- heap -> blocks = base + sizeof (Heap );
126
+ heap -> blocks = ( Block * ) ( base + sizeof (Heap ) );
127
127
128
128
Block * block = heap -> blocks ;
129
129
size_t i = heap_max_blocks - 1 ;
@@ -163,7 +163,7 @@ static Block *alloc_block(size_t num) {
163
163
size_t top = heap -> top ;
164
164
num = (num + heap_alignment - 1 ) & - heap_alignment ;
165
165
while (ptr != NULL ) {
166
- const int is_top = ((size_t )ptr -> addr + ptr -> size >= top ) && ((size_t )ptr -> addr + num <= heap_limit );
166
+ const int is_top = ((size_t )ptr -> addr + ptr -> size >= top ) && ((size_t )ptr -> addr + num <= ( size_t ) heap_limit );
167
167
if (is_top || ptr -> size >= num ) {
168
168
if (prev != NULL ) {
169
169
prev -> next = ptr -> next ;
@@ -202,7 +202,7 @@ static Block *alloc_block(size_t num) {
202
202
// no matching free blocks
203
203
// see if any other blocks available
204
204
size_t new_top = top + num ;
205
- if (heap -> fresh != NULL && new_top <= heap_limit ) {
205
+ if (heap -> fresh != NULL && new_top <= ( size_t ) heap_limit ) {
206
206
ptr = heap -> fresh ;
207
207
heap -> fresh = ptr -> next ;
208
208
ptr -> addr = (void * )top ;
0 commit comments