1 /*********************************************************************
4 * Empties all memory regions so that their entire buffer space is
5 * considered unused. This allows the client to restart without
6 * having to reallocate memory for the allocator regions, which helps
7 * performance when this package gets used serially.
8 *********************************************************************/
11 malloc_region * cur_region;
13 queue_iterate(&malloc_region_list, cur_region, malloc_region *, links) {
15 queue_init(&cur_region->block_list);
16 cur_region->free_size = cur_region->region_size - sizeof(malloc_region);
17 cur_region->free_address = &cur_region->buffer;
21 queue_init(&sorted_free_block_list);
24 current_block_total = 0;
25 #endif /* CLIENT_DEBUG */
32 /*********************************************************************
35 *********************************************************************/
37 size_t malloc_size(void * address) {
38 malloc_region * found_region = NULL;
39 malloc_block * found_block = NULL;
41 malloc_find_block(address, &found_block, &found_region);
44 /* If we couldn't find the requested block,
45 * the caller is in error so return 0.
47 if (found_block == NULL) {
52 return (found_block->block_size - sizeof(malloc_block));
57 /*********************************************************************
60 *********************************************************************/
62 int malloc_is_valid(void * address){
63 malloc_region * found_region = NULL;
64 malloc_block * found_block = NULL;
66 malloc_find_block(address, &found_block, &found_region);
68 if (found_block != NULL) {
74 } /* malloc_is_valid() */