Module: kamailio
Branch: master
Commit: 126cfa51be8718082e20e268cf14d0649c60b17d
URL:
https://github.com/kamailio/kamailio/commit/126cfa51be8718082e20e268cf14d06…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-05-23T09:30:51+02:00
core: xvavp - new data type SR_XTYPE_SPTR
- store a shm pointer that has to be freed at destroy with shm_free()
---
Modified: src/core/xavp.c
Modified: src/core/xavp.h
---
Diff:
https://github.com/kamailio/kamailio/commit/126cfa51be8718082e20e268cf14d06…
Patch:
https://github.com/kamailio/kamailio/commit/126cfa51be8718082e20e268cf14d06…
---
diff --git a/src/core/xavp.c b/src/core/xavp.c
index f9b0fd627f..b3a2654764 100644
--- a/src/core/xavp.c
+++ b/src/core/xavp.c
@@ -57,6 +57,10 @@ void xavp_free(sr_xavp_t *xa)
xa->val.v.data->pfree(xa->val.v.data->p, xavp_shm_free);
shm_free(xa->val.v.data);
}
+ } else if(xa->val.type == SR_XTYPE_SPTR) {
+ if(xa->val.v.vptr) {
+ shm_free(xa->val.v.vptr);
+ }
} else if(xa->val.type == SR_XTYPE_XAVP) {
xavp_destroy_list(&xa->val.v.xavp);
}
@@ -70,6 +74,10 @@ void xavp_free_unsafe(sr_xavp_t *xa)
xa->val.v.data->pfree(xa->val.v.data->p, xavp_shm_free_unsafe);
shm_free_unsafe(xa->val.v.data);
}
+ } else if(xa->val.type == SR_XTYPE_SPTR) {
+ if(xa->val.v.vptr) {
+ shm_free_unsafe(xa->val.v.vptr);
+ }
} else if(xa->val.type == SR_XTYPE_XAVP) {
xavp_destroy_list_unsafe(&xa->val.v.xavp);
}
@@ -588,6 +596,9 @@ void xavp_print_list_content(sr_xavp_t **head, int level)
case SR_XTYPE_VPTR:
LM_INFO(" XAVP value: <vptr:%p>\n", avp->val.v.vptr);
break;
+ case SR_XTYPE_SPTR:
+ LM_INFO(" XAVP value: <sptr:%p>\n", avp->val.v.vptr);
+ break;
case SR_XTYPE_DATA:
LM_INFO(" XAVP value: <data:%p>\n", avp->val.v.data);
break;
@@ -697,7 +708,7 @@ sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold)
{
return NULL;
}
- if(xold->val.type==SR_XTYPE_DATA)
+ if(xold->val.type==SR_XTYPE_DATA || xold->val.type==SR_XTYPE_SPTR)
{
LM_INFO("xavp value type is 'data' - ignoring in clone\n");
return NULL;
@@ -720,7 +731,8 @@ sr_xavp_t *xavp_clone_level_nodata(sr_xavp_t *xold)
while(oavp)
{
- if(oavp->val.type!=SR_XTYPE_DATA && oavp->val.type!=SR_XTYPE_XAVP)
+ if(oavp->val.type!=SR_XTYPE_DATA && oavp->val.type!=SR_XTYPE_XAVP
+ && oavp->val.type!=SR_XTYPE_SPTR)
{
navp = xavp_new_value(&oavp->name, &oavp->val);
if(navp==NULL)
diff --git a/src/core/xavp.h b/src/core/xavp.h
index 4f440ea612..84af5ad182 100644
--- a/src/core/xavp.h
+++ b/src/core/xavp.h
@@ -33,7 +33,8 @@ typedef enum {
SR_XTYPE_LONG, /* long value */
SR_XTYPE_LLONG, /* long long value */
SR_XTYPE_XAVP, /* xavp value */
- SR_XTYPE_VPTR, /* void pointer value */
+ SR_XTYPE_VPTR, /* void pointer value (no free on destroy) */
+ SR_XTYPE_SPTR, /* void pointer value (shm free on destroy) */
SR_XTYPE_DATA /* custom data value */
} sr_xtype_t;