From d2ce1d65681de2703ce9906d2f702e8d6e899899 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 26 Feb 2017 22:31:54 -0500 Subject: [PATCH] valgrind findings --- c/containers/xvfuncs.c | 3 +++ c/dsl/rval_expr_evaluators.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/c/containers/xvfuncs.c b/c/containers/xvfuncs.c index d5ac39aca..e2e1b6fa2 100644 --- a/c/containers/xvfuncs.c +++ b/c/containers/xvfuncs.c @@ -195,7 +195,10 @@ boxed_xval_t m_ss_splitnvx_xfunc(boxed_xval_t* pstringval, boxed_xval_t* psepval char* piece; while ((piece = strsep(&walker, sep)) != NULL) { mv_t key = mv_from_int(i); + // xxx do not ref here mv_t val = mv_ref_type_infer_string(piece); + // xxx make clear the copy/ref semantics for mlhmmv put with scalar value. + // at the moment this does an mv_copy. mlhmmv_level_put_terminal_singly_keyed(map.pnext_level, &key, &val); i++; } diff --git a/c/dsl/rval_expr_evaluators.c b/c/dsl/rval_expr_evaluators.c index 29b0cf698..206ec6732 100644 --- a/c/dsl/rval_expr_evaluators.c +++ b/c/dsl/rval_expr_evaluators.c @@ -971,8 +971,8 @@ mv_t get_srec_value_string_only(char* field_name, lrec_t* pinrec, lhmsmv_t* ptyp // freed out from underneath it by the evaluator functions. rv = mv_copy(poverlay); } else { - // No strdup: string value points into lrec memory and is valid as long as the lrec is. rv = mv_ref_type_infer_string(lrec_get(pinrec, field_name)); + rv = mv_copy(&rv); } return rv; } @@ -988,8 +988,8 @@ mv_t get_srec_value_string_float(char* field_name, lrec_t* pinrec, lhmsmv_t* pty // freed out from underneath it by the evaluator functions. rv = mv_copy(poverlay); } else { - // No strdup: string value points into lrec memory and is valid as long as the lrec is. rv = mv_ref_type_infer_string_or_float(lrec_get(pinrec, field_name)); + rv = mv_copy(&rv); } return rv; } @@ -1005,8 +1005,8 @@ mv_t get_srec_value_string_float_int(char* field_name, lrec_t* pinrec, lhmsmv_t* // freed out from underneath it by the evaluator functions. rv = mv_copy(poverlay); } else { - // No strdup: string value points into lrec memory and is valid as long as the lrec is. rv = mv_ref_type_infer_string_or_float_or_int(lrec_get(pinrec, field_name)); + rv = mv_copy(&rv); } return rv; }