Changeset 709 for soft/giet_vm/giet_libs/malloc.c
- Timestamp:
- Oct 1, 2015, 4:20:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_libs/malloc.c
r686 r709 98 98 99 99 // checking heap segment constraints 100 if ( heap_size == 0 ) // heap segment exist 101 { 102 giet_exit("ERROR in malloc() : heap not found \n"); 103 } 104 if ( heap_size != (1<<heap_index) ) // heap size power of 2 105 { 106 giet_exit("ERROR in malloc() : heap size must be power of 2\n"); 107 } 108 if ( heap_base % heap_size ) // heap segment aligned 109 { 110 giet_exit("ERROR in malloc() : heap segment must be aligned\n"); 111 } 100 giet_pthread_assert( (heap_size != 0) , 101 "error in heap_init() : heap not found"); 102 giet_pthread_assert( (heap_size == (1<<heap_index)) , 103 "error in heap_init() : heap size must be power of 2"); 104 giet_pthread_assert( (heap_base%heap_size == 0) , 105 "error in heap_init() : heap segment must be aligned\n"); 112 106 113 107 // compute size of block containin alloc[] array … … 231 225 232 226 // checking arguments 233 if (size == 0) 234 { 235 giet_exit("\nERROR in remote_malloc() : requested size = 0 \n"); 236 } 237 if ( x >= X_SIZE ) 238 { 239 giet_exit("\nERROR in remote_malloc() : x coordinate too large\n"); 240 } 241 if ( y >= Y_SIZE ) 242 { 243 giet_exit("\nERROR in remote_malloc() : y coordinate too large\n"); 244 } 245 246 // checking initialization 247 if ( heap[x][y].init != HEAP_INITIALIZED ) 248 { 249 giet_exit("\nERROR in remote_malloc() : heap not initialized\n"); 250 } 227 giet_pthread_assert( (size != 0) , 228 "error in remote_malloc() : requested size = 0 \n"); 229 giet_pthread_assert( (x < X_SIZE) , 230 "error in remote_malloc() : x coordinate too large\n"); 231 giet_pthread_assert( (y < Y_SIZE) , 232 "error in remote_malloc() : y coordinate too large\n"); 233 giet_pthread_assert( (heap[x][y].init == HEAP_INITIALIZED) , 234 "error in remote_malloc() : heap not initialized\n"); 251 235 252 236 // normalize size … … 265 249 266 250 // check block found 267 if ( base == 0)251 if (base == 0) 268 252 { 269 253 lock_release( &heap[x][y].lock ); 270 giet_ exit("\nERROR in remote_malloc() : no more space\n");254 giet_pthread_assert( 0 , "error in remote_malloc() : no more space\n" ); 271 255 } 272 256 … … 279 263 { 280 264 lock_release( &heap[x][y].lock ); 281 giet_ exit("\nERROR in remote_malloc() : block already allocated ???\n");265 giet_pthread_assert( 0 , "error in remote_malloc() : block already allocated"); 282 266 } 283 267 … … 390 374 // check ptr value 391 375 unsigned int base = (unsigned int)ptr; 392 if ( (base < heap[x][y].heap_base) || 393 (base >= (heap[x][y].heap_base + heap[x][y].heap_size)) ) 394 { 395 giet_exit("ERROR in free() : illegal pointer for released block"); 396 } 376 giet_pthread_assert( (base >= heap[x][y].heap_base) && 377 (base < (heap[x][y].heap_base + heap[x][y].heap_size)) , 378 "error in free() : illegal pointer for released block" ); 397 379 398 380 // get the lock protecting heap[x][y] … … 410 392 { 411 393 lock_release( &heap[x][y].lock ); 412 giet_ exit("\nERROR in free() : released block not allocated ???\n");394 giet_pthread_assert( 0 , "error in free() : released block not allocated"); 413 395 } 414 396 … … 416 398 if ( base % (1 << size_index) ) 417 399 { 418 giet_exit("\nERROR in free() : released block not aligned\n"); 400 lock_release( &heap[x][y].lock ); 401 giet_pthread_assert( 0 , "error in free() : released block not aligned"); 419 402 } 420 403
Note: See TracChangeset
for help on using the changeset viewer.