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

Function _hpt_malloc

mem/test/test_malloc.c:71–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69};
70
71static void _hpt_malloc(unsigned int frag_overhead)
72{
73 struct hpt_frag *ret;
74 ssize_t size;
75
76 if (!check_limit()) {
77 should_grow = 0;
78 return;
79 }
80
81 size = (rand() % HPT_FAC) * (HPT_MAX_ALLOC_SZ/HPT_FAC) + 1;
82
83 ret = MALLOC(sizeof *ret + size);
84 if (!ret) {
85 LM_ERR("oom\n");
86 should_grow = 0;
87 return;
88 }
89 memset(ret, -1, sizeof *ret + size);
90
91 if ((unsigned long)ret % MEM_ALIGN == 0)
92 aligned_mallocs++;
93
94 ret->chunk = (void *)(ret + 1);
95 ret->size = size;
96
97 list_add(&ret->list, &hpt_frags);
98
99 hpt_my_used += size + sizeof *ret + frag_overhead;
100 mallocs++;
101 fragments++;
102}
103
104static void _hpt_realloc(unsigned int frag_overhead)
105{

Callers 1

_hpt_reallocFunction · 0.85

Calls 1

list_addFunction · 0.85

Tested by

no test coverage detected