From 72e7cbee88c393cbd18bbcf27ec2be9df220fb9b Mon Sep 17 00:00:00 2001 From: Guillaume Souchere Date: Thu, 13 Oct 2022 16:00:09 +0200 Subject: [PATCH] heap: Remove size check in multi_heap.c when registering a new heap The tlsf now checks for size validity when creating a new heap. The check previously done in multi_heap_register_impl() is no longer valid since the tlsf_size() is not known at this time (as the metadata size is linked ot the size of the memory region passed as parameter when calling tlsf_create_with_pool()) The tlsf_create_with_pool() will return a null pointer if the size of the memory is not big enough to hold the metadata overhead and at least a small block. Update the test according to the changes in TLSF API --- components/heap/multi_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/heap/multi_heap.c b/components/heap/multi_heap.c index e167b3b357..05477806d4 100644 --- a/components/heap/multi_heap.c +++ b/components/heap/multi_heap.c @@ -129,7 +129,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(NULL) + tlsf_block_size_min() + sizeof(heap_t))) { + if(size < (sizeof(heap_t))) { //Region too small to be a heap. return NULL; }