|
|
@@ -195,32 +195,36 @@ void *multi_heap_aligned_alloc(multi_heap_handle_t heap, size_t size, size_t ali
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
+ if(!alignment) {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
//Alignment must be a power of two...
|
|
|
if((alignment & (alignment - 1)) != 0) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- if(size > SIZE_MAX - POISON_OVERHEAD) {
|
|
|
+ if(size > SIZE_MAX /* - POISON_OVERHEAD*/) {
|
|
|
return NULL;
|
|
|
}
|
|
|
|
|
|
- uint32_t overhead = (sizeof(uint32_t) + (alignment - 1) + POISON_OVERHEAD);
|
|
|
+ uint32_t overhead = (sizeof(uint32_t) + (alignment - 1) /*+ POISON_OVERHEAD*/);
|
|
|
|
|
|
multi_heap_internal_lock(heap);
|
|
|
poison_head_t *head = multi_heap_malloc_impl(heap, size + overhead);
|
|
|
- uint8_t *data = NULL;
|
|
|
+ //uint8_t *data = NULL;
|
|
|
if (head != NULL) {
|
|
|
- data = poison_allocated_region(head, size);
|
|
|
+ //data = poison_allocated_region(head, size);
|
|
|
#ifdef SLOW
|
|
|
/* check everything we got back is FREE_FILL_PATTERN & swap for MALLOC_FILL_PATTERN */
|
|
|
- bool ret = verify_fill_pattern(data, size, true, true, true);
|
|
|
- assert( ret );
|
|
|
+ //bool ret = verify_fill_pattern(data, size, true, true, true);
|
|
|
+ //assert( ret );
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
//Lets align our new obtained block address:
|
|
|
//and save the original heap pointer to allow deallocation
|
|
|
- void *ptr = (void *)ALIGN_UP((uintptr_t)head + sizeof(uint32_t) + POISON_OVERHEAD, alignment);
|
|
|
+ void *ptr = (void *)ALIGN_UP((uintptr_t)head + sizeof(uint32_t) /* + POISON_OVERHEAD*/, alignment);
|
|
|
*((uint32_t *)ptr - 1) = (uint32_t)((uintptr_t)ptr - (uintptr_t)head);
|
|
|
|
|
|
multi_heap_internal_unlock(heap);
|
|
|
@@ -258,19 +262,17 @@ void multi_heap_aligned_free(multi_heap_handle_t heap, void *p)
|
|
|
multi_heap_internal_lock(heap);
|
|
|
|
|
|
uint32_t offset = *((uint32_t *)p - 1);
|
|
|
- void *block_head = (void *)((uint8_t *)p - (offset - POISON_OVERHEAD));
|
|
|
+ void *block_head = (void *)((uint8_t *)p - (offset /*- POISON_OVERHEAD*/));
|
|
|
|
|
|
- poison_head_t *head = verify_allocated_region(block_head, true);
|
|
|
- assert(head != NULL);
|
|
|
+ /* poison_head_t *head = verify_allocated_region(block_head, true);
|
|
|
+ assert(head != NULL); */
|
|
|
|
|
|
#ifdef SLOW
|
|
|
/* replace everything with FREE_FILL_PATTERN, including the poison head/tail */
|
|
|
- memset(head, FREE_FILL_PATTERN,
|
|
|
- head->alloc_size + POISON_OVERHEAD);
|
|
|
+ //memset(head, FREE_FILL_PATTERN, head->alloc_size + POISON_OVERHEAD);
|
|
|
#endif
|
|
|
|
|
|
- multi_heap_free_impl(heap, head);
|
|
|
-
|
|
|
+ multi_heap_free_impl(heap, block_head);
|
|
|
multi_heap_internal_unlock(heap);
|
|
|
}
|
|
|
|