123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include <string.h>
- #include <assert.h>
- #include "cache.h"
- lub_heap_status_t
- lub_heap_realloc(lub_heap_t * this,
- char **ptr, size_t requested_size, lub_heap_align_t alignment)
- {
- lub_heap_status_t status = LUB_HEAP_FAILED;
- size_t size = requested_size;
-
- lub_heap_pre_realloc(this, ptr, &size);
- if (this->cache && (LUB_HEAP_ALIGN_NATIVE == alignment)) {
-
- status = lub_heap_cache_realloc(this, ptr, size);
- } else {
-
- status = lub_heap_raw_realloc(this, ptr, size, alignment);
- }
-
- lub_heap_post_realloc(this, ptr);
- if (LUB_HEAP_OK == status) {
-
- if ((this->stats.alloc_bytes + this->stats.alloc_overhead)
- > (this->stats.alloc_hightide_bytes +
- this->stats.alloc_hightide_overhead)) {
- this->stats.alloc_hightide_blocks =
- this->stats.alloc_blocks;
- this->stats.alloc_hightide_bytes =
- this->stats.alloc_bytes;
- this->stats.alloc_hightide_overhead =
- this->stats.alloc_overhead;
- this->stats.free_hightide_blocks =
- this->stats.free_blocks;
- this->stats.free_hightide_bytes =
- this->stats.free_bytes;
- this->stats.free_hightide_overhead =
- this->stats.free_overhead;
- }
- } else {
-
- lub_heap_stop_here(status, *ptr, requested_size);
- }
- if ((0 == requested_size) && (NULL == *ptr) && (LUB_HEAP_OK == status)) {
-
- *ptr = LUB_HEAP_ZERO_ALLOC;
- }
- return status;
- }
|