Changeset 0c33b1d5 in mainline
- Timestamp:
- 2011-05-20T23:58:26Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 955f2a5
- Parents:
- c263c77
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/malloc.c
rc263c77 r0c33b1d5 119 119 (((uintptr_t) (head)) + (head)->size - sizeof(heap_block_foot_t))) 120 120 121 #define malloc_assert(expr) \ 122 do { \ 123 if (!(expr)) {\ 124 futex_up(&malloc_futex); \ 125 assert((expr)); \ 126 } \ 127 } while (0) 128 129 121 130 /** Heap area. 122 131 * … … 228 237 heap_block_head_t *head = (heap_block_head_t *) addr; 229 238 230 assert(head->magic == HEAP_BLOCK_HEAD_MAGIC);239 malloc_assert(head->magic == HEAP_BLOCK_HEAD_MAGIC); 231 240 232 241 heap_block_foot_t *foot = BLOCK_FOOT(head); 233 242 234 assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC);235 assert(head->size == foot->size);243 malloc_assert(foot->magic == HEAP_BLOCK_FOOT_MAGIC); 244 malloc_assert(head->size == foot->size); 236 245 } 237 246 … … 247 256 heap_area_t *area = (heap_area_t *) addr; 248 257 249 assert(area->magic == HEAP_AREA_MAGIC);250 assert(addr == area->start);251 assert(area->start < area->end);252 assert(((uintptr_t) area->start % PAGE_SIZE) == 0);253 assert(((uintptr_t) area->end % PAGE_SIZE) == 0);258 malloc_assert(area->magic == HEAP_AREA_MAGIC); 259 malloc_assert(addr == area->start); 260 malloc_assert(area->start < area->end); 261 malloc_assert(((uintptr_t) area->start % PAGE_SIZE) == 0); 262 malloc_assert(((uintptr_t) area->end % PAGE_SIZE) == 0); 254 263 } 255 264 … … 382 391 383 392 block_check((void *) last_head); 384 assert(last_head->area == area);393 malloc_assert(last_head->area == area); 385 394 386 395 if (last_head->free) { … … 395 404 396 405 block_check((void *) first_head); 397 assert(first_head->area == area);406 malloc_assert(first_head->area == area); 398 407 399 408 size_t shrink_size = ALIGN_DOWN(last_head->size, PAGE_SIZE); … … 497 506 static void split_mark(heap_block_head_t *cur, const size_t size) 498 507 { 499 assert(cur->size >= size);508 malloc_assert(cur->size >= size); 500 509 501 510 /* See if we should split the block. */ … … 533 542 { 534 543 area_check((void *) area); 535 assert((void *) first_block >= (void *) AREA_FIRST_BLOCK_HEAD(area));536 assert((void *) first_block < area->end);544 malloc_assert((void *) first_block >= (void *) AREA_FIRST_BLOCK_HEAD(area)); 545 malloc_assert((void *) first_block < area->end); 537 546 538 547 for (heap_block_head_t *cur = first_block; (void *) cur < area->end; … … 661 670 static void *malloc_internal(const size_t size, const size_t align) 662 671 { 663 assert(first_heap_area != NULL);672 malloc_assert(first_heap_area != NULL); 664 673 665 674 if (align == 0) … … 786 795 787 796 block_check(head); 788 assert(!head->free);797 malloc_assert(!head->free); 789 798 790 799 heap_area_t *area = head->area; 791 800 792 801 area_check(area); 793 assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));794 assert((void *) head < area->end);802 malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area)); 803 malloc_assert((void *) head < area->end); 795 804 796 805 void *ptr = NULL; … … 863 872 864 873 block_check(head); 865 assert(!head->free);874 malloc_assert(!head->free); 866 875 867 876 heap_area_t *area = head->area; 868 877 869 878 area_check(area); 870 assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area));871 assert((void *) head < area->end);879 malloc_assert((void *) head >= (void *) AREA_FIRST_BLOCK_HEAD(area)); 880 malloc_assert((void *) head < area->end); 872 881 873 882 /* Mark the block itself as free. */
Note:
See TracChangeset
for help on using the changeset viewer.