@@ -26,7 +26,7 @@ typedef struct {
2626} Heap ;
2727
2828static Heap * heap = NULL ;
29- static void * heap_limit = NULL ;
29+ static const void * heap_limit = NULL ;
3030static size_t heap_split_thresh ;
3131static size_t heap_alignment ;
3232static size_t heap_max_blocks ;
@@ -123,7 +123,7 @@ bool ta_init(const void *base, const void *limit, const size_t heap_blocks, cons
123123 heap -> used = NULL ;
124124 heap -> fresh = heap -> blocks ;
125125 heap -> top = (size_t )base + sizeof (Heap ) + heap_blocks * sizeof (Block );
126- heap -> blocks = base + sizeof (Heap );
126+ heap -> blocks = ( Block * ) ( base + sizeof (Heap ) );
127127
128128 Block * block = heap -> blocks ;
129129 size_t i = heap_max_blocks - 1 ;
@@ -163,7 +163,7 @@ static Block *alloc_block(size_t num) {
163163 size_t top = heap -> top ;
164164 num = (num + heap_alignment - 1 ) & - heap_alignment ;
165165 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 );
167167 if (is_top || ptr -> size >= num ) {
168168 if (prev != NULL ) {
169169 prev -> next = ptr -> next ;
@@ -202,7 +202,7 @@ static Block *alloc_block(size_t num) {
202202 // no matching free blocks
203203 // see if any other blocks available
204204 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 ) {
206206 ptr = heap -> fresh ;
207207 heap -> fresh = ptr -> next ;
208208 ptr -> addr = (void * )top ;
0 commit comments