cores
cores copied to clipboard
don't set do_zero flag when initializing extmem heap (improve performance when allocating)
Currently when the extmem_smalloc_pool is created, the do_zero flag is set which causes smalloc to always zero out allocated memory. This reduces allocation performance since it's only required by calls to calloc, not malloc.
This patch unsets the do_zero flag, manually clears any statically allocated EXTMEM memory (which wasn't being done before in violation of C spec - uninitialized static data should be zeroed) and makes extmem_calloc() call sm_calloc_pool() instead of sm_malloc_pool().
Updated the patch; with do_zero==false smalloc only clears smalloc_hdr contents when memory is free'd. This makes allocations persist across reboots unless the pool is cleared at startup. So the entire extmem must be zeroed, not just the static allocations between _extram_start and _extram_end.