Skip to content

Commit

Permalink
statsc: convert to memory logging helper, free memory in case of error
Browse files Browse the repository at this point in the history
  • Loading branch information
pantelisk98 authored and henningw committed Apr 24, 2023
1 parent 7747f91 commit d5ab93a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/modules/statsc/statsc_mod.c
Expand Up @@ -202,7 +202,7 @@ int statsc_nmap_add(str *sname, str *rname)
+ STRLEN_ROUNDUP(sname->len) + STRLEN_ROUNDUP(rname->len);
sm = shm_malloc(sz);
if(sm==NULL) {
LM_ERR("no more shared memory\n");
SHM_MEM_ERROR;
return -1;
}
memset(sm, 0, sz);
Expand Down Expand Up @@ -241,7 +241,7 @@ int statsc_init(void)

_statsc_info = shm_malloc(sizeof(statsc_info_t));
if(_statsc_info==NULL) {
LM_ERR("no more shared memory\n");
SHM_MEM_ERROR;
return -1;
}
memset(_statsc_info, 0, sizeof(statsc_info_t));
Expand All @@ -250,7 +250,8 @@ int statsc_init(void)
sz = sizeof(statsc_nmap_t) + statsc_items * sizeof(int64_t);
sm = shm_malloc(sz);
if(sm==NULL) {
LM_ERR("no more shared memory\n");
SHM_MEM_ERROR;
shm_free(_statsc_info);
return -1;
}
memset(sm, 0, sz);
Expand Down

0 comments on commit d5ab93a

Please sign in to comment.