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

Function xode_pool_malloc

modules/xmpp/xpool.c:137–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void *xode_pool_malloc(xode_pool p, int size)
138{
139 void *block;
140
141 if(p == NULL)
142 {
143 fprintf(stderr,"Memory Leak! xode_pmalloc received NULL pool, unable to track allocation, exiting]\n");
144 abort();
145 }
146
147 /* if there is no heap for this pool or it's a big request, just raw, I like how we clean this :) */
148 if(p->heap == NULL || size > (p->heap->size / 2))
149 {
150 while((block = _xode_pool__malloc(size)) == NULL) sleep(1);
151 p->size += size;
152 _xode_pool_cleanup_append(p, _xode_pool_free(p, _xode_pool__free, block));
153 return block;
154 }
155
156 /* we have to preserve boundaries, long story :) */
157 if(size >= 4)
158 while(p->heap->used&7) p->heap->used++;
159
160 /* if we don't fit in the old heap, replace it */
161 if(size > (p->heap->size - p->heap->used))
162 p->heap = _xode_pool_heap(p, p->heap->size);
163
164 /* the current heap has room */
165 block = (char *)p->heap->block + p->heap->used;
166 p->heap->used += size;
167 return block;
168}
169
170void *xode_pool_mallocx(xode_pool p, int size, char c)
171{

Callers 11

xode_pool_mallocxFunction · 0.70
xode_pool_mallocoFunction · 0.70
xode_pool_strdupFunction · 0.70
xode_spool_newfrompoolFunction · 0.70
xode_spool_addFunction · 0.70
xode_spool_tostrFunction · 0.70
xode_strunescapeFunction · 0.70
xode_strescapeFunction · 0.70
_xode_newFunction · 0.70
_xode_mergeFunction · 0.70
xode_insert_cdataFunction · 0.70

Calls 3

_xode_pool_freeFunction · 0.70
_xode_pool_heapFunction · 0.70

Tested by

no test coverage detected