From 1519f0212f02a83ca3cd4857514f90a138bd260d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 18 Apr 2006 10:28:03 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 4 ++-- ase/awk/run.c | 13 +++++++++---- ase/awk/val.c | 12 ++++++++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 9d22c0f8..13bfb038 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.51 2006-04-17 16:12:02 bacon Exp $ + * $Id: awk.h,v 1.52 2006-04-18 10:28:03 bacon Exp $ */ #ifndef _XP_AWK_AWK_H_ @@ -80,7 +80,7 @@ enum XP_AWK_ENOSUCHFUNC, /* no such function */ XP_AWK_ENOTASSIGNABLE, /* not indexable value */ XP_AWK_ENOTINDEXABLE, /* not indexable value */ - XP_AWK_EINDEX, /* wrong index */ + XP_AWK_EWRONGINDEX, /* wrong index */ XP_AWK_EINTERNAL /* internal error */ }; diff --git a/ase/awk/run.c b/ase/awk/run.c index d9a725e4..36f50d10 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.54 2006-04-17 16:12:02 bacon Exp $ + * $Id: run.c,v 1.55 2006-04-18 10:28:03 bacon Exp $ */ #include @@ -884,14 +884,16 @@ static xp_awk_val_t* __do_assignment_globalidx ( /* TODO: how to tell memory from conversion error? */ xp_awk_refdownval (awk, tmp); /*PANIC (awk, XP_AWK_ENOMEM);*/ - PANIC (awk, XP_AWK_EINDEX); + PANIC (awk, XP_AWK_EWRONGINDEX); } xp_awk_refdownval (awk, tmp); /* TODO: nde = nde->next; */ } +/* xp_printf (XP_TEXT("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, map->ref, map->type); +*/ pair = xp_awk_map_get (map->map, str); if (xp_awk_map_put(map->map, str, val) == XP_NULL) { @@ -899,9 +901,12 @@ xp_printf (XP_TEXT("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, map- PANIC (awk, XP_AWK_ENOMEM); } - xp_free (str); if (pair != XP_NULL) { + /* str is freed only if the key is in the map. + * otherwise, it will be taken by the map */ + xp_free (str); + /* decrease the reference count for the old value * only when the assignment is successful */ xp_awk_refdownval (awk, pair->val); @@ -2182,7 +2187,7 @@ static xp_awk_val_t* __eval_globalidx (xp_awk_t* awk, xp_awk_nde_t* nde) /* TODO: how to tell memory error from conversion error? */ xp_awk_refdownval (awk, idx); /*PANIC (awk, XP_AWK_ENOMEM);*/ - PANIC (awk, XP_AWK_EINDEX); + PANIC (awk, XP_AWK_EWRONGINDEX); } /* TODO: check this out........ */ diff --git a/ase/awk/val.c b/ase/awk/val.c index 101fa8e8..0e800dce 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.20 2006-04-17 16:12:02 bacon Exp $ + * $Id: val.c,v 1.21 2006-04-18 10:28:03 bacon Exp $ */ #include @@ -122,6 +122,11 @@ xp_awk_val_t* xp_awk_makestrval2 ( static void __free_map_val (xp_awk_t* awk, void* v) { +/* +xp_printf (XP_TEXT("refdown in map free...")); +xp_awk_printval (v); +xp_printf (XP_TEXT("\n")); +*/ xp_awk_refdownval (awk, v); } @@ -129,7 +134,7 @@ xp_awk_val_t* xp_awk_makemapval (xp_awk_t* awk) { xp_awk_val_map_t* val; - val = (xp_awk_val_map_t*)xp_malloc(xp_sizeof(xp_awk_val_map_t)); + val = (xp_awk_val_map_t*) xp_malloc (xp_sizeof(xp_awk_val_map_t)); if (val == XP_NULL) return XP_NULL; val->type = XP_AWK_VAL_MAP; @@ -155,6 +160,9 @@ void xp_awk_freeval (xp_awk_t* awk, xp_awk_val_t* val) { if (xp_awk_isbuiltinval(val)) return; +xp_printf (XP_TEXT("freeing ... ")); +xp_awk_printval (val); +xp_printf (XP_TEXT("\n")); switch (val->type) { case XP_AWK_VAL_NIL: