1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #include <assert.h>
- #include "private.h"
- void
- lub_heap_graft_to_top(lub_heap_t * this,
- lub_heap_block_t * free_block,
- void *ptr,
- words_t words, bool_t seg_end, bool_t other_free_block)
- {
- lub_heap_tag_t *tail;
- assert(1 == free_block->free.tag.free);
-
- lub_bintree_remove(&this->free_tree, free_block);
- if (BOOL_FALSE == other_free_block) {
- tail = lub_heap_block__get_tail(free_block);
-
- lub_heap_taint_memory((char *)tail,
- LUB_HEAP_TAINT_FREE,
- (words << 2) + sizeof(lub_heap_tag_t));
- } else {
- char *tmp = ptr;
-
- lub_heap_taint_memory(tmp - sizeof(lub_heap_tag_t),
- LUB_HEAP_TAINT_FREE,
- sizeof(lub_heap_tag_t) +
- sizeof(lub_heap_free_block_t));
- }
-
- free_block->free.tag.words += words;
- this->stats.free_bytes += (words << 2);
-
- tail = lub_heap_block__get_tail(free_block);
- tail->segment = seg_end;
- tail->free = 1;
-
- tail->words = free_block->free.tag.words;
-
- lub_bintree_insert(&this->free_tree, free_block);
- }
|