MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / hp_shm_malloc_init

Function hp_shm_malloc_init

mem/hp_malloc.c:606–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

604}
605
606struct hp_block *hp_shm_malloc_init(char *address, unsigned long size,
607 char *name)
608{
609 struct hp_block *hpb;
610
611 hpb = hp_malloc_init(address, size, name);
612 if (!hpb) {
613 LM_ERR("failed to initialize shm block\n");
614 return NULL;
615 }
616
617#ifdef HP_MALLOC_FAST_STATS
618 hpb->free_hash[PEEK_HASH_RR(hpb, hpb->first_frag->size)].total_no++;
619#endif
620
621#ifdef HP_MALLOC_FAST_STATS
622#ifdef DBG_MALLOC
623 hp_stats_lock = hp_shm_malloc_unsafe(hpb, sizeof *hp_stats_lock,
624 __FILE__, __FUNCTION__, __LINE__);
625#else
626 hp_stats_lock = hp_shm_malloc_unsafe(hpb, sizeof *hp_stats_lock);
627#endif
628 if (!hp_stats_lock) {
629 LM_ERR("failed to alloc hp statistics lock\n");
630 return NULL;
631 }
632
633 if (!lock_init(hp_stats_lock)) {
634 LM_CRIT("could not initialize hp statistics lock\n");
635 return NULL;
636 }
637#endif
638
639 return hpb;
640}
641
642
643#ifdef SHM_EXTRA_STATS

Callers 3

rpm_mem_init_mallocsFunction · 0.85
shm_mem_init_mallocsFunction · 0.85
shm_dbg_mem_init_mallocsFunction · 0.85

Calls 3

hp_malloc_initFunction · 0.85
hp_shm_malloc_unsafeFunction · 0.85
lock_initFunction · 0.85

Tested by

no test coverage detected