Module: kamailio Branch: master Commit: 767fb51adbaecf37a0812731d9bf63a86f2b3c0e URL: https://github.com/kamailio/kamailio/commit/767fb51adbaecf37a0812731d9bf63a8...
Author: Luis Azedo luis@2600hz.com Committer: Luis Azedo luis@2600hz.com Date: 2015-01-05T13:24:39Z
kazoo : fix transform
---
Modified: modules/kazoo/kz_json.c Modified: modules/kazoo/kz_trans.c
---
Diff: https://github.com/kamailio/kamailio/commit/767fb51adbaecf37a0812731d9bf63a8... Patch: https://github.com/kamailio/kamailio/commit/767fb51adbaecf37a0812731d9bf63a8...
---
diff --git a/modules/kazoo/kz_json.c b/modules/kazoo/kz_json.c index 2d6c731..9c538b7 100644 --- a/modules/kazoo/kz_json.c +++ b/modules/kazoo/kz_json.c @@ -30,6 +30,7 @@
#include "kz_json.h"
+static str kz_pv_str_empty {"", 0};
char** str_split(char* a_str, const char a_delim) { @@ -150,8 +151,11 @@ int kz_json_get_field_ex(str* json, str* field, pv_value_p dst_val) dst_val->rs.s[len] = '\0'; dst_val->rs.len = len; dst_val->flags = PV_VAL_STR | PV_VAL_PKG; + dst_val->ri = 0; } else { dst_val->flags = PV_VAL_NULL; + dst_val->rs kz_pv_str_empty; + dst_val->ri = 0; }
json_object_put(j); diff --git a/modules/kazoo/kz_trans.c b/modules/kazoo/kz_trans.c index a753b93..32e38e6 100644 --- a/modules/kazoo/kz_trans.c +++ b/modules/kazoo/kz_trans.c @@ -133,8 +133,9 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val return -1; }
+ /* // it seems that val memory is not freed - // event with flag set to PV_VAL_PKG + // even with flag set to PV_VAL_PKG
strncpy(_kz_tr_buffer, val->rs.s, val->rs.len); if(val->flags & PV_VAL_PKG) @@ -145,6 +146,7 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val val->flags = PV_VAL_STR; val->ri = 0; val->rs.s = _kz_tr_buffer; + */
if(oldflags & PV_VAL_PKG) { pkg_free(tofree); @@ -168,8 +170,10 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val LM_ERR("error getting json\n"); return -1; } + + /* // it seems that val memory is not freed - // event with flag set to PV_VAL_PKG + // even with flag set to PV_VAL_PKG
strncpy(_kz_tr_buffer, val->rs.s, val->rs.len); if(val->flags & PV_VAL_PKG) @@ -180,6 +184,7 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val val->flags = PV_VAL_STR; val->ri = 0; val->rs.s = _kz_tr_buffer; + */
if(oldflags & PV_VAL_PKG) { pkg_free(tofree);
On Monday 05 January 2015, Luis Azedo wrote:
Author: Luis Azedo luis@2600hz.com Committer: Luis Azedo luis@2600hz.com Date: 2015-01-05T13:24:39Z
kazoo : fix transform
Could you maybe add an a little more verbose commit message. For example, what transformation is fixed and what was wrong with it.
@@ -150,8 +151,11 @@ int kz_json_get_field_ex(str* json, str* field, pv_value_p dst_val) dst_val->rs.s[len] = '\0'; dst_val->rs.len = len; dst_val->flags = PV_VAL_STR | PV_VAL_PKG;
} else { dst_val->flags = PV_VAL_NULL;dst_val->ri = 0;
dst_val->rs kz_pv_str_empty;
dst_val->ri = 0;
This is messing up the indentation and makes the code hard to read.
Indentation style is, unfortunately, not very consistent throughout kamailio, but should at least be consistent with the surrounding code.
}
json_object_put(j); diff --git a/modules/kazoo/kz_trans.c b/modules/kazoo/kz_trans.c index a753b93..32e38e6 100644 --- a/modules/kazoo/kz_trans.c +++ b/modules/kazoo/kz_trans.c @@ -133,8 +133,9 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val return -1; }
/* // it seems that val memory is not freed
// event with flag set to PV_VAL_PKG
// even with flag set to PV_VAL_PKG strncpy(_kz_tr_buffer, val->rs.s, val->rs.len); if(val->flags & PV_VAL_PKG)
@@ -145,6 +146,7 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val val->flags = PV_VAL_STR; val->ri = 0; val->rs.s = _kz_tr_buffer;
*/ if(oldflags & PV_VAL_PKG) { pkg_free(tofree);
@@ -168,8 +170,10 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val LM_ERR("error getting json\n"); return -1; }
/* // it seems that val memory is not freed
// event with flag set to PV_VAL_PKG
// even with flag set to PV_VAL_PKG strncpy(_kz_tr_buffer, val->rs.s, val->rs.len); if(val->flags & PV_VAL_PKG)
@@ -180,6 +184,7 @@ int kz_tr_eval(struct sip_msg *msg, tr_param_t *tp, int subtype, pv_value_t *val val->flags = PV_VAL_STR; val->ri = 0; val->rs.s = _kz_tr_buffer;
*/ if(oldflags & PV_VAL_PKG) { pkg_free(tofree);
Why is the code commented and not removed?