Skip to content

Commit

Permalink
xcap_server: convert to memory logging helper, improve mem error hand…
Browse files Browse the repository at this point in the history
…ling
  • Loading branch information
pantelisk98 authored and henningw committed Apr 21, 2023
1 parent 070279f commit 30f3bb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/modules/xcap_server/xcap_misc.c
Expand Up @@ -589,7 +589,7 @@ int xcaps_xpath_set(str *inbuf, str *xpaths, str *val, str *outbuf)
outbuf->s = (char*)pkg_malloc(size+1);
if(outbuf->s==NULL)
{
LM_ERR("no pkg for output\n");
PKG_MEM_ERROR_FMT("for output\n");
xmlFree(xmem);
goto error;
}
Expand Down Expand Up @@ -643,7 +643,7 @@ int xcaps_xpath_ns_param(modparam_t type, void *val)

if(ns==NULL)
{
LM_ERR("no more pkg\n");
PKG_MEM_ERROR;
goto error;
}
memset(ns, 0, sizeof(param_t));
Expand Down Expand Up @@ -735,7 +735,7 @@ pv_xcap_uri_t *pv_xcap_uri_get_struct(str *name)
it = (pv_xcap_uri_t*)pkg_malloc(sizeof(pv_xcap_uri_t));
if(it==NULL)
{
LM_ERR("no more pkg\n");
PKG_MEM_ERROR;
return NULL;
}
memset(it, 0, sizeof(pv_xcap_uri_t));
Expand All @@ -762,8 +762,10 @@ int pv_parse_xcap_uri_name(pv_spec_p sp, str *in)

pxs = (pv_xcap_uri_spec_t*)pkg_malloc(sizeof(pv_xcap_uri_spec_t));
if(pxs==NULL)
{
PKG_MEM_ERROR;
return -1;

}
memset(pxs, 0, sizeof(pv_xcap_uri_spec_t));

p = in->s;
Expand Down
13 changes: 9 additions & 4 deletions src/modules/xcap_server/xcap_server.c
Expand Up @@ -171,7 +171,7 @@ static int mod_init(void)
xcaps_buf.s = (char*)pkg_malloc(xcaps_buf.len+1);
if(xcaps_buf.s==NULL)
{
LM_ERR("no pkg\n");
PKG_MEM_ERROR;
return -1;
}

Expand Down Expand Up @@ -266,7 +266,7 @@ static int xcaps_send_reply(sip_msg_t *msg, int code, str *reason,

if (tbuf.len==0)
{
LM_ERR("out of pkg memory\n");
PKG_MEM_ERROR;
return -1;
}
memcpy(tbuf.s, "Content-Type: ", sizeof("Content-Type: ") - 1);
Expand Down Expand Up @@ -545,7 +545,7 @@ static int ki_xcaps_put(sip_msg_t* msg, str* uri, str* path,
body.s = (char*)pkg_malloc(pbody->len+1);
if(body.s==NULL)
{
LM_ERR("no more pkg\n");
PKG_MEM_ERROR;
goto error;
}
memcpy(body.s, pbody->s, pbody->len);
Expand Down Expand Up @@ -1033,6 +1033,11 @@ static int xcaps_get_directory(struct sip_msg *msg, str *user, str *domain, str
else
{
server_name.s = pkg_malloc(IP6_MAX_STR_SIZE + 6);
if(!server_name.s)
{
PKG_MEM_ERROR;
goto error;
}
server_name.len = ip_addr2sbuf(&msg->rcv.dst_ip, server_name.s, IP6_MAX_STR_SIZE);
directory->len += snprintf(directory->s + directory->len,
xcaps_buf.len - directory->len,
Expand Down Expand Up @@ -1172,7 +1177,7 @@ static int ki_xcaps_get(sip_msg_t* msg, str* uri, str* path)
{
if((new_body.s = pkg_malloc(body.len))==NULL)
{
LM_ERR("allocating package memory\n");
PKG_MEM_ERROR;
goto error;
}
new_body.len = body.len;
Expand Down

0 comments on commit 30f3bb9

Please sign in to comment.