Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/umm_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@ static uint16_t umm_assimilate_down(umm_heap *heap, uint16_t c, uint16_t freemas
/* ------------------------------------------------------------------------- */

void umm_multi_init_heap(umm_heap *heap, void *ptr, size_t size) {
/* Guard against too many blocks for 15-bit indices */
if ((size / UMM_BLOCKSIZE) > UMM_BLOCKNO_MASK)
{
/* Try increasing UMM_BLOCKSIZE if this hits */
DBGLOG_CRITICAL("Heap too large: %u blocks (max %u)\n",
(unsigned) UMM_NUMBLOCKS, (unsigned) UMM_BLOCKNO_MASK);

/* Mark this heap as unusable */
heap->pheap = NULL;
UMM_HEAPSIZE = 0;
UMM_NUMBLOCKS = 0;

return;
}

/* init heap pointer and size, and memset it to 0 */
heap->pheap = ptr;
UMM_HEAPSIZE = size;
Expand Down Expand Up @@ -799,4 +814,4 @@ void *umm_realloc(void *ptr, size_t size){

void umm_free(void *ptr){
umm_multi_free(&umm_heap_current, ptr);
}
}