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

Function __add_stat_module

statistics.c:187–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static inline module_stats* __add_stat_module(str *module, int unsafe)
188{
189 module_stats *amods;
190 module_stats *mods;
191
192 if ( (module==0) || module->len==0 )
193 return NULL;
194
195 amods = unsafe ?
196 (module_stats*)shm_realloc_unsafe( collector->amodules,
197 (collector->mod_no+1)*sizeof(module_stats))
198 :
199 (module_stats*)shm_realloc( collector->amodules,
200 (collector->mod_no+1)*sizeof(module_stats));
201
202 if (amods==0) {
203 LM_ERR("no more shm memory\n");
204 return NULL;
205 }
206
207 collector->amodules = amods;
208 collector->mod_no++;
209
210 mods = &amods[collector->mod_no-1];
211 memset( mods, 0, sizeof(module_stats) );
212
213 mods->name.s = unsafe ? shm_malloc_unsafe(module->len) : shm_malloc(module->len);
214 if (!mods->name.s) {
215 LM_ERR("oom\n");
216 return NULL;
217 }
218 memcpy(mods->name.s, module->s, module->len);
219 mods->name.len = module->len;
220
221 mods->idx = collector->mod_no-1;
222
223 return mods;
224}
225
226module_stats *add_stat_module(char *module)
227{

Callers 2

add_stat_moduleFunction · 0.85
__register_statFunction · 0.85

Calls 4

shm_realloc_unsafeFunction · 0.85
shm_reallocFunction · 0.85
shm_malloc_unsafeFunction · 0.85
shm_mallocFunction · 0.85

Tested by

no test coverage detected