fix: make sure we have "heartbeats" even when `-D SMALL_ALLOC=OFF"
This commit is contained in:
parent
da5d46cd5d
commit
4848533717
2 changed files with 8 additions and 2 deletions
|
|
@ -310,6 +310,7 @@ static inline unsigned lean_get_slot_idx(unsigned sz) {
|
|||
void * lean_alloc_small(unsigned sz, unsigned slot_idx);
|
||||
void lean_free_small(void * p);
|
||||
unsigned lean_small_mem_size(void * p);
|
||||
void lean_inc_heartbeat();
|
||||
|
||||
static inline lean_object * lean_alloc_small_object(unsigned sz) {
|
||||
#ifdef LEAN_SMALL_ALLOCATOR
|
||||
|
|
@ -318,6 +319,7 @@ static inline lean_object * lean_alloc_small_object(unsigned sz) {
|
|||
assert(sz <= LEAN_MAX_SMALL_OBJECT_SIZE);
|
||||
return (lean_object*)lean_alloc_small(sz, slot_idx);
|
||||
#else
|
||||
lean_inc_heartbeat();
|
||||
void * mem = malloc(sizeof(size_t) + sz);
|
||||
if (mem == 0) lean_panic_out_of_memory();
|
||||
*(size_t*)mem = sz;
|
||||
|
|
|
|||
|
|
@ -389,6 +389,12 @@ extern "C" void * lean_alloc_small(unsigned sz, unsigned slot_idx) {
|
|||
return r;
|
||||
}
|
||||
|
||||
/* Helper function for increasing hearbeat even when LEAN_SMALL_ALLOCATOR is not defined */
|
||||
extern "C" void lean_inc_heartbeat() {
|
||||
if (g_heap)
|
||||
g_heap->m_heartbeat++;
|
||||
}
|
||||
|
||||
uint64_t get_num_heartbeats() {
|
||||
if (g_heap)
|
||||
return g_heap->m_heartbeat;
|
||||
|
|
@ -449,10 +455,8 @@ extern "C" unsigned lean_small_mem_size(void * o) {
|
|||
}
|
||||
|
||||
void initialize_alloc() {
|
||||
#ifdef LEAN_SMALL_ALLOCATOR
|
||||
g_heap_manager = new heap_manager();
|
||||
init_heap(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void finalize_alloc() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue