Skip to content

Commit

Permalink
siputils: convert to memory logging helper
Browse files Browse the repository at this point in the history
  • Loading branch information
pantelisk98 authored and henningw committed Apr 24, 2023
1 parent d5ab93a commit f7588fb
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/modules/siputils/chargingvector.c
Expand Up @@ -329,7 +329,7 @@ static int sip_add_charging_vector(struct sip_msg *msg)

s = (char*)pkg_malloc(pcv.len);
if (!s) {
LM_ERR("no pkg memory left\n");
PKG_MEM_ERROR;
return -1;
}
memcpy(s, pcv.s, pcv.len );
Expand Down
8 changes: 4 additions & 4 deletions src/modules/siputils/checks.c
Expand Up @@ -388,7 +388,7 @@ int ki_add_uri_param(struct sip_msg* _msg, str* param)
}
new_uri.s = pkg_malloc(new_uri.len);
if (new_uri.s == 0) {
LM_ERR("add_uri_param(): Memory allocation failure\n");
PKG_MEM_ERROR;
return -1;
}
memcpy(new_uri.s, cur_uri->s, cur_uri->len);
Expand Down Expand Up @@ -416,7 +416,7 @@ int ki_add_uri_param(struct sip_msg* _msg, str* param)

new_uri.s = pkg_malloc(new_uri.len);
if (new_uri.s == 0) {
LM_ERR("no more pkg memory\n");
PKG_MEM_ERROR;
return -1;
}

Expand Down Expand Up @@ -603,7 +603,7 @@ int tel2sip(struct sip_msg* _msg, char* _uri, char* _hostpart, char* _res)
/* reserve memory for clean tel uri */
tel_uri.s = pkg_malloc(uri.len+1);
if (tel_uri.s == 0) {
LM_ERR("no more pkg memory\n");
PKG_MEM_ERROR;
return -1;
}

Expand All @@ -629,7 +629,7 @@ int tel2sip(struct sip_msg* _msg, char* _uri, char* _hostpart, char* _res)
sip_uri.len = 4 + tel_uri.len - 4 + 1 + hostpart.len + 1 + 10;
sip_uri.s = pkg_malloc(sip_uri.len+1);
if (sip_uri.s == 0) {
LM_ERR("no more pkg memory\n");
PKG_MEM_ERROR;
pkg_free(tel_uri.s);
return -1;
}
Expand Down
6 changes: 2 additions & 4 deletions src/modules/siputils/contact_ops.c
Expand Up @@ -373,9 +373,8 @@ int encode_uri(str uri, char *encoding_prefix, char *public_ip, char separator,
result->s = pkg_malloc(result->len);
pos = result->s;
if(pos == NULL) {
LM_DBG("unable to alloc result [%d] end=[%d]\n", result->len,
PKG_MEM_ERROR_FMT("unable to alloc result [%d] end=[%d]\n", result->len,
format.second);
LM_ERR("unable to alloc pkg memory\n");
return -3;
}
LM_DBG("pass=[%d]i: allocated [%d], bytes.first=[%d] lengthsec=[%d];"
Expand Down Expand Up @@ -581,11 +580,10 @@ int decode_uri(str uri, char separator, str *result)
/* adding one comes from * */
result->s = pkg_malloc(result->len + 1); /* NULL termination */
if(result->s == NULL) {
LM_ERR("unable to allocate pkg memory\n");
PKG_MEM_ERROR;
return -4;
}
pos = result->s;

LM_DBG("Adding [%.*s]\n", format.first, uri.s);

memcpy(pos, uri.s, format.first); /* till sip: */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/siputils/options.c
Expand Up @@ -68,7 +68,7 @@ int ki_opt_reply(struct sip_msg* _msg) {
+ opt_accept_lang.len + opt_supported.len;
rpl_hf.s = (char*)pkg_malloc(rpl_hf.len);
if (!rpl_hf.s) {
LM_CRIT("out of pkg memory\n");
PKG_MEM_CRITICAL;
goto error;
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/siputils/rpid.c
Expand Up @@ -162,7 +162,7 @@ int append_rpid_hf(struct sip_msg* _m, char* _s1, char* _s2)
+ rpid_suffix.len + CRLF_LEN;
rpid_hf.s = pkg_malloc(rpid_hf.len);
if (!rpid_hf.s) {
LM_ERR("no memory left\n");
PKG_MEM_ERROR;
return -1;
}

Expand Down Expand Up @@ -228,7 +228,7 @@ int append_rpid_hf_p(struct sip_msg* _m, char* _prefix, char* _suffix)
rpid_hf.len = RPID_HF_NAME_LEN + p->len + rpid.len + s->len + CRLF_LEN;
rpid_hf.s = pkg_malloc(rpid_hf.len);
if (!rpid_hf.s) {
LM_ERR("no pkg memory left\n");
PKG_MEM_ERROR;
return -1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/siputils/utils.c
Expand Up @@ -100,7 +100,7 @@ patch_content_length (struct sip_msg *msg, unsigned int newValue)
s = pkg_malloc (len);
if (s == NULL)
{
LM_ERR("unable to allocate %d bytes in pkg mem\n", len);
PKG_MEM_ERROR_FMT("missing %d bytes\n", len);
return -3;
}
memcpy (s, pos, len);
Expand Down

0 comments on commit f7588fb

Please sign in to comment.