Module: kamailio Branch: master Commit: 5e75d1cfd08390e561508bac3e762518ce8c422b URL: https://github.com/kamailio/kamailio/commit/5e75d1cfd08390e561508bac3e762518ce8c422b
Author: Daniel-Constantin Mierla <[email protected]> Committer: Daniel-Constantin Mierla <[email protected]> Date: 2025-10-10T15:19:33+02:00 core: coreparam - helper function to set a string value inside pkg-alloced (str*)->s --- Modified: src/core/coreparam.c --- Diff: https://github.com/kamailio/kamailio/commit/5e75d1cfd08390e561508bac3e762518ce8c422b.diff Patch: https://github.com/kamailio/kamailio/commit/5e75d1cfd08390e561508bac3e762518ce8c422b.patch --- diff --git a/src/core/coreparam.c b/src/core/coreparam.c index e1e362c5fd4..de20d36e278 100644 --- a/src/core/coreparam.c +++ b/src/core/coreparam.c @@ -22,9 +22,11 @@ #include "dprint.h" #include "rand/ksrxrand.h" +#include "mem/pkg.h" #include "coreparam.h" int ksr_coreparam_store_nval(str *pname, ksr_cpval_t *pval, void *eparam); +int ksr_coreparam_store_sval_pkg(str *pname, ksr_cpval_t *pval, void *eparam); long ksr_timer_sanity_check = 0; /* clang-format off */ @@ -93,3 +95,28 @@ int ksr_coreparam_store_nval(str *pname, ksr_cpval_t *pval, void *eparam) *(long *)eparam = pval->v.nval; return 0; } + +/** + * store the value in a str* variable, with v->s field allocated in pkg + * - target v->s has to be initially null or pkg-alloced to cope properly + * with setting the parameters many times + */ +int ksr_coreparam_store_sval_pkg(str *pname, ksr_cpval_t *pval, void *eparam) +{ + str *v; + + v = (str *)eparam; + if(v == NULL) { + LM_ERR("store parameter not provided\n"); + return -1; + } + if(v->s != NULL) { + pkg_free(v->s); + } + v->len = strlen(pval->v.sval); + v->s = (char *)pkg_malloc(v->len + 1); + memcpy(v->s, pval->v.sval, v->len); + v->s[v->len] = '\0'; + + return 0; +} _______________________________________________ Kamailio - Development Mailing List -- [email protected] To unsubscribe send an email to [email protected] Important: keep the mailing list in the recipients, do not reply only to the sender!
