Module: kamailio Branch: master Commit: d49ffadbcae8b3dd9fc7ede43940ab223d57a35b URL: https://github.com/kamailio/kamailio/commit/d49ffadbcae8b3dd9fc7ede43940ab22...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-03-08T09:04:58+01:00
htable: exported get_clone api function to return pkg clone for item
- alternative to GH #1866
---
Modified: src/modules/htable/api.c Modified: src/modules/htable/api.h
---
Diff: https://github.com/kamailio/kamailio/commit/d49ffadbcae8b3dd9fc7ede43940ab22... Patch: https://github.com/kamailio/kamailio/commit/d49ffadbcae8b3dd9fc7ede43940ab22...
---
diff --git a/src/modules/htable/api.c b/src/modules/htable/api.c index 616f00a0ea..5b4a61af9f 100644 --- a/src/modules/htable/api.c +++ b/src/modules/htable/api.c @@ -91,6 +91,19 @@ int ht_api_get_cell_expire(str *hname, str *name, return ht_get_cell_expire(ht, name, val); }
+/** + * get a clone in pkg for an htable item + * - returned pointer must be pkg_free() after use + */ +ht_cell_t* ht_api_get_cell_clone(str *hname, str *name) +{ + ht_t* ht; + ht = ht_get_table(hname); + if(ht==NULL) + return NULL; + return ht_cell_pkg_copy(ht, name, NULL); +} + /** * */ @@ -137,6 +150,7 @@ int bind_htable(htable_api_t* api) return -1; } api->set = ht_api_set_cell; + api->get_clone = ht_api_get_cell_clone; api->rm = ht_api_del_cell; api->set_expire = ht_api_set_cell_expire; api->get_expire = ht_api_get_cell_expire; diff --git a/src/modules/htable/api.h b/src/modules/htable/api.h index b7a8849f08..da1fea94e8 100644 --- a/src/modules/htable/api.h +++ b/src/modules/htable/api.h @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - + #ifndef _HT_MOD_API_H_ #define _HT_MOD_API_H_
@@ -27,6 +27,7 @@
typedef int (*ht_api_set_cell_f)(str *hname, str *name, int type, int_str *val, int mode); +typedef ht_cell_t* (*ht_api_get_cell_clone_f)(str *hname, str *name); typedef int (*ht_api_del_cell_f)(str *hname, str *name);
typedef int (*ht_api_set_cell_expire_f)(str *hname, str *name, @@ -39,6 +40,7 @@ typedef int (*ht_api_count_cells_re_f)(str *hname, str *sre, int mode);
typedef struct htable_api { ht_api_set_cell_f set; + ht_api_get_cell_clone_f get_clone; ht_api_del_cell_f rm; ht_api_set_cell_expire_f set_expire; ht_api_get_cell_expire_f get_expire;