|
|
@@ -142,7 +142,7 @@ size_t multi_heap_get_allocated_size_impl(multi_heap_handle_t heap, void *p)
|
|
|
multi_heap_handle_t multi_heap_register_impl(void *start_ptr, size_t size)
|
|
|
{
|
|
|
assert(start_ptr);
|
|
|
- if(size < (tlsf_size() + tlsf_block_size_min() + sizeof(heap_t))) {
|
|
|
+ if(size < (tlsf_size(NULL) + tlsf_block_size_min() + sizeof(heap_t))) {
|
|
|
//Region too small to be a heap.
|
|
|
return NULL;
|
|
|
}
|
|
|
@@ -150,13 +150,16 @@ multi_heap_handle_t multi_heap_register_impl(void *start_ptr, size_t size)
|
|
|
heap_t *result = (heap_t *)start_ptr;
|
|
|
size -= sizeof(heap_t);
|
|
|
|
|
|
- result->heap_data = tlsf_create_with_pool(start_ptr + sizeof(heap_t), size);
|
|
|
+ /* Do not specify any maximum size for the allocations so that the default configuration is used */
|
|
|
+ const size_t max_bytes = 0;
|
|
|
+
|
|
|
+ result->heap_data = tlsf_create_with_pool(start_ptr + sizeof(heap_t), size, max_bytes);
|
|
|
if(!result->heap_data) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
result->lock = NULL;
|
|
|
- result->free_bytes = size - tlsf_size();
|
|
|
+ result->free_bytes = size - tlsf_size(result->heap_data);
|
|
|
result->pool_size = size;
|
|
|
result->minimum_free_bytes = result->free_bytes;
|
|
|
return result;
|
|
|
@@ -417,7 +420,6 @@ static void multi_heap_get_info_tlsf(void* ptr, size_t size, int used, void* use
|
|
|
|
|
|
void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info)
|
|
|
{
|
|
|
- uint32_t sl_interval;
|
|
|
uint32_t overhead;
|
|
|
|
|
|
memset(info, 0, sizeof(multi_heap_info_t));
|
|
|
@@ -431,13 +433,10 @@ void multi_heap_get_info_impl(multi_heap_handle_t heap, multi_heap_info_t *info)
|
|
|
/* TLSF has an overhead per block. Calculate the total amount of overhead, it shall not be
|
|
|
* part of the allocated bytes */
|
|
|
overhead = info->allocated_blocks * tlsf_alloc_overhead();
|
|
|
- info->total_allocated_bytes = (heap->pool_size - tlsf_size()) - heap->free_bytes - overhead;
|
|
|
+ info->total_allocated_bytes = (heap->pool_size - tlsf_size(heap->heap_data)) - heap->free_bytes - overhead;
|
|
|
info->minimum_free_bytes = heap->minimum_free_bytes;
|
|
|
info->total_free_bytes = heap->free_bytes;
|
|
|
- if (info->largest_free_block) {
|
|
|
- sl_interval = (1 << (31 - __builtin_clz(info->largest_free_block))) / SL_INDEX_COUNT;
|
|
|
- info->largest_free_block = info->largest_free_block & ~(sl_interval - 1);
|
|
|
- }
|
|
|
+ info->largest_free_block = tlsf_fit_size(heap->heap_data, info->largest_free_block);
|
|
|
multi_heap_internal_unlock(heap);
|
|
|
}
|
|
|
#endif
|