more touch-up

This commit is contained in:
hyung-hwan 2019-06-07 05:20:20 +00:00
parent e8cfcfce44
commit 040ee69eb7
8 changed files with 353 additions and 437 deletions

View File

@ -448,6 +448,7 @@ struct qse_awk_fun_t
{ {
qse_cstr_t name; qse_cstr_t name;
qse_size_t nargs; qse_size_t nargs;
qse_char_t* argspec; /* similar to the argument spec of qse_awk_fnc_arg_t. supports v & r only */
qse_awk_nde_t* body; qse_awk_nde_t* body;
}; };
typedef struct qse_awk_fun_t qse_awk_fun_t; typedef struct qse_awk_fun_t qse_awk_fun_t;

View File

@ -33,17 +33,17 @@ static void free_fun (qse_htb_t* map, void* vptr, qse_size_t vlen)
qse_awk_fun_t* f = (qse_awk_fun_t*)vptr; qse_awk_fun_t* f = (qse_awk_fun_t*)vptr;
/* f->name doesn't have to be freed */ /* f->name doesn't have to be freed */
/*QSE_AWK_FREE (awk, f->name);*/ /*qse_awk_freemem (awk, f->name);*/
qse_awk_clrpt (awk, f->body); qse_awk_clrpt (awk, f->body);
QSE_AWK_FREE (awk, f); qse_awk_freemem (awk, f);
} }
static void free_fnc (qse_htb_t* map, void* vptr, qse_size_t vlen) static void free_fnc (qse_htb_t* map, void* vptr, qse_size_t vlen)
{ {
qse_awk_t* awk = *(qse_awk_t**)QSE_XTN(map); qse_awk_t* awk = *(qse_awk_t**)QSE_XTN(map);
qse_awk_fnc_t* f = (qse_awk_fnc_t*)vptr; qse_awk_fnc_t* f = (qse_awk_fnc_t*)vptr;
QSE_AWK_FREE (awk, f); qse_awk_freemem (awk, f);
} }
static int init_token (qse_mmgr_t* mmgr, qse_awk_tok_t* tok) static int init_token (qse_mmgr_t* mmgr, qse_awk_tok_t* tok)
@ -299,7 +299,7 @@ void qse_awk_fini (qse_awk_t* awk)
/* destroy dynamically allocated options */ /* destroy dynamically allocated options */
for (i = 0; i < QSE_COUNTOF(awk->opt.mod); i++) for (i = 0; i < QSE_COUNTOF(awk->opt.mod); i++)
{ {
if (awk->opt.mod[i].ptr) QSE_AWK_FREE (awk, awk->opt.mod[i].ptr); if (awk->opt.mod[i].ptr) qse_awk_freemem (awk, awk->opt.mod[i].ptr);
} }
} }
@ -385,7 +385,7 @@ void qse_awk_clear (qse_awk_t* awk)
qse_awk_clrpt (awk, awk->tree.chain->pattern); qse_awk_clrpt (awk, awk->tree.chain->pattern);
if (awk->tree.chain->action != QSE_NULL) if (awk->tree.chain->action != QSE_NULL)
qse_awk_clrpt (awk, awk->tree.chain->action); qse_awk_clrpt (awk, awk->tree.chain->action);
QSE_AWK_FREE (awk, awk->tree.chain); qse_awk_freemem (awk, awk->tree.chain);
awk->tree.chain = next; awk->tree.chain = next;
} }
@ -452,7 +452,7 @@ int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
if (dup_str_opt (awk, value, &tmp) <= -1) return -1; if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
idx = id - QSE_AWK_MODPREFIX; idx = id - QSE_AWK_MODPREFIX;
if (awk->opt.mod[idx].ptr) QSE_AWK_FREE (awk, awk->opt.mod[idx].ptr); if (awk->opt.mod[idx].ptr) qse_awk_freemem (awk, awk->opt.mod[idx].ptr);
awk->opt.mod[idx] = tmp; awk->opt.mod[idx] = tmp;
return 0; return 0;
@ -462,7 +462,7 @@ int qse_awk_setopt (qse_awk_t* awk, qse_awk_opt_t id, const void* value)
{ {
qse_cstr_t tmp; qse_cstr_t tmp;
if (dup_str_opt (awk, value, &tmp) <= -1) return -1; if (dup_str_opt (awk, value, &tmp) <= -1) return -1;
if (awk->opt.incldirs.ptr) QSE_AWK_FREE (awk, awk->opt.incldirs.ptr); if (awk->opt.incldirs.ptr) qse_awk_freemem (awk, awk->opt.incldirs.ptr);
awk->opt.incldirs = tmp; awk->opt.incldirs = tmp;
return 0; return 0;
} }

View File

@ -128,7 +128,7 @@ qse_awk_fnc_t* qse_awk_addfnc (qse_awk_t* awk, const qse_char_t* name, const qse
speclen = spec->arg.spec? qse_strlen(spec->arg.spec): 0; speclen = spec->arg.spec? qse_strlen(spec->arg.spec): 0;
fnc_size = QSE_SIZEOF(*fnc) + (ncs.len + 1 + speclen + 1) * QSE_SIZEOF(qse_char_t); fnc_size = QSE_SIZEOF(*fnc) + (ncs.len + 1 + speclen + 1) * QSE_SIZEOF(qse_char_t);
fnc = (qse_awk_fnc_t*) qse_awk_callocmem (awk, fnc_size); fnc = (qse_awk_fnc_t*)qse_awk_callocmem(awk, fnc_size);
if (fnc) if (fnc)
{ {
qse_char_t* tmp; qse_char_t* tmp;
@ -145,11 +145,11 @@ qse_awk_fnc_t* qse_awk_addfnc (qse_awk_t* awk, const qse_char_t* name, const qse
fnc->spec.arg.spec = tmp; fnc->spec.arg.spec = tmp;
} }
if (qse_htb_insert (awk->fnc.user, if (qse_htb_insert(awk->fnc.user, (qse_char_t*)ncs.ptr, ncs.len, fnc, 0) == QSE_NULL)
(qse_char_t*)ncs.ptr, ncs.len, fnc, 0) == QSE_NULL)
{ {
qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_seterrnum (awk, QSE_AWK_ENOMEM, QSE_NULL);
QSE_AWK_FREE (awk, fnc); fnc = QSE_NULL; qse_awk_freemem (awk, fnc);
fnc = QSE_NULL;
} }
} }
@ -163,7 +163,7 @@ int qse_awk_delfnc (qse_awk_t* awk, const qse_char_t* name)
ncs.ptr = (qse_char_t*)name; ncs.ptr = (qse_char_t*)name;
ncs.len = qse_strlen (name); ncs.len = qse_strlen (name);
if (qse_htb_delete (awk->fnc.user, ncs.ptr, ncs.len) <= -1) if (qse_htb_delete(awk->fnc.user, ncs.ptr, ncs.len) <= -1)
{ {
qse_awk_seterrnum (awk, QSE_AWK_ENOENT, &ncs); qse_awk_seterrnum (awk, QSE_AWK_ENOENT, &ncs);
return -1; return -1;
@ -276,8 +276,7 @@ static int fnc_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
* flagged by the return value of close(). * flagged by the return value of close().
if (n <= -1 && rtx->errinf.num != QSE_AWK_EIONMNF) if (n <= -1 && rtx->errinf.num != QSE_AWK_EIONMNF)
{ {
if (a0->type != QSE_AWK_VAL_STR) if (a0->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, name);
QSE_AWK_FREE (rtx->awk, name);
return -1; return -1;
} }
*/ */
@ -601,13 +600,13 @@ int qse_awk_fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
default: default:
/* convert to string and get length */ /* convert to string and get length */
str = qse_awk_rtx_valtostrdup(rtx, v, &len); str = qse_awk_rtx_valtostrdup(rtx, v, &len);
if (str == QSE_NULL) return -1; if (!str) return -1;
QSE_AWK_FREE (rtx->awk, str); qse_awk_rtx_freemem (rtx, str);
} }
} }
v = qse_awk_rtx_makeintval(rtx, len); v = qse_awk_rtx_makeintval(rtx, len);
if (v == QSE_NULL) return -1; if (!v) return -1;
qse_awk_rtx_setretval (rtx, v); qse_awk_rtx_setretval (rtx, v);
return 0; return 0;
@ -842,7 +841,7 @@ int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
str.len = str_left - (p - str.ptr); str.len = str_left - (p - str.ptr);
} }
/*if (str_free) QSE_AWK_FREE (rtx->awk, str_free);*/ /*if (str_free) qse_awk_rtx_freemem (rtx, str_free);*/
qse_awk_rtx_freevalstr (rtx, a0, str.ptr); qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
if (fs_free) qse_awk_rtx_freemem (rtx, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
@ -864,7 +863,7 @@ int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
return 0; return 0;
oops: oops:
/*if (str_free) QSE_AWK_FREE (rtx->awk, str_free);*/ /*if (str_free) qse_awk_rtx_freemem (rtx, str_free);*/
if (str.ptr) qse_awk_rtx_freevalstr (rtx, a0, str.ptr); if (str.ptr) qse_awk_rtx_freevalstr (rtx, a0, str.ptr);
if (fs_free) qse_awk_rtx_freemem (rtx, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
@ -1182,11 +1181,11 @@ static int __substitute (qse_awk_rtx_t* rtx, qse_awk_int_t max_count)
qse_str_fini (&new); qse_str_fini (&new);
if (s2_free) QSE_AWK_FREE (rtx->awk, s2_free); if (s2_free) qse_awk_rtx_freemem (rtx, s2_free);
qse_awk_rtx_freevalstr (rtx, a1, s1.ptr); qse_awk_rtx_freevalstr (rtx, a1, s1.ptr);
if (s0_free) QSE_AWK_FREE (rtx->awk, s0_free); if (s0_free) qse_awk_rtx_freemem (rtx, s0_free);
v = qse_awk_rtx_makeintval (rtx, sub_count); v = qse_awk_rtx_makeintval (rtx, sub_count);
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
@ -1203,9 +1202,9 @@ oops:
qse_awk_freerex (rtx->awk, rex_free, QSE_NULL); qse_awk_freerex (rtx->awk, rex_free, QSE_NULL);
} }
if (new_inited) qse_str_fini (&new); if (new_inited) qse_str_fini (&new);
if (s2_free) QSE_AWK_FREE (rtx->awk, s2_free); if (s2_free) qse_awk_rtx_freemem (rtx, s2_free);
if (s1.ptr) qse_awk_rtx_freevalstr (rtx, a1, s1.ptr); if (s1.ptr) qse_awk_rtx_freevalstr (rtx, a1, s1.ptr);
if (s0_free) QSE_AWK_FREE (rtx->awk, s0_free); if (s0_free) qse_awk_rtx_freemem (rtx, s0_free);
return -1; return -1;
} }

View File

@ -622,7 +622,7 @@ oops:
prev = awk->sio.inp->prev; prev = awk->sio.inp->prev;
QSE_ASSERT (awk->sio.inp->name != QSE_NULL); QSE_ASSERT (awk->sio.inp->name != QSE_NULL);
QSE_AWK_FREE (awk, awk->sio.inp); qse_awk_freemem (awk, awk->sio.inp);
awk->sio.inp = prev; awk->sio.inp = prev;
} }
@ -634,8 +634,7 @@ oops:
CLRERR (awk); CLRERR (awk);
} }
if (awk->sio.inf ( if (awk->sio.inf(awk, QSE_AWK_SIO_CLOSE, awk->sio.inp, QSE_NULL, 0) != 0)
awk, QSE_AWK_SIO_CLOSE, awk->sio.inp, QSE_NULL, 0) != 0)
{ {
if (ret == 0) if (ret == 0)
{ {
@ -663,7 +662,7 @@ void qse_awk_clearsionames (qse_awk_t* awk)
{ {
cur = awk->sio_names; cur = awk->sio_names;
awk->sio_names = cur->link; awk->sio_names = cur->link;
QSE_AWK_FREE (awk, cur); qse_awk_freemem (awk, cur);
} }
} }
@ -2626,7 +2625,7 @@ static qse_awk_nde_t* parse_return (qse_awk_t* awk, const qse_awk_loc_t* xloc)
val = parse_expr_withdc (awk, &eloc); val = parse_expr_withdc (awk, &eloc);
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -2666,7 +2665,7 @@ static qse_awk_nde_t* parse_exit (qse_awk_t* awk, const qse_awk_loc_t* xloc)
val = parse_expr_withdc (awk, &eloc); val = parse_expr_withdc (awk, &eloc);
if (val == QSE_NULL) if (val == QSE_NULL)
{ {
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -2971,7 +2970,7 @@ static qse_awk_nde_t* parse_print (qse_awk_t* awk, const qse_awk_loc_t* xloc)
out = ep->right; out = ep->right;
out_type = tab[i].out; out_type = tab[i].out;
QSE_AWK_FREE (awk, tmp); qse_awk_freemem (awk, tmp);
break; break;
} }
} }
@ -3672,7 +3671,7 @@ static QSE_INLINE void update_int_node (
node->val = lv; node->val = lv;
if (node->str) if (node->str)
{ {
QSE_AWK_FREE (awk, node->str); qse_awk_freemem (awk, node->str);
node->str = QSE_NULL; node->str = QSE_NULL;
node->len = 0; node->len = 0;
} }
@ -3684,7 +3683,7 @@ static QSE_INLINE void update_flt_node (
node->val = rv; node->val = rv;
if (node->str) if (node->str)
{ {
QSE_AWK_FREE (awk, node->str); qse_awk_freemem (awk, node->str);
node->str = QSE_NULL; node->str = QSE_NULL;
node->len = 0; node->len = 0;
} }
@ -4432,8 +4431,8 @@ static qse_awk_nde_t* parse_primary_int (qse_awk_t* awk, const qse_awk_loc_t* x
oops: oops:
QSE_ASSERT (nde != QSE_NULL); QSE_ASSERT (nde != QSE_NULL);
if (nde->str) QSE_AWK_FREE (awk, nde->str); if (nde->str) qse_awk_freemem (awk, nde->str);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
@ -4466,8 +4465,8 @@ static qse_awk_nde_t* parse_primary_flt (qse_awk_t* awk, const qse_awk_loc_t* x
oops: oops:
QSE_ASSERT (nde != QSE_NULL); QSE_ASSERT (nde != QSE_NULL);
if (nde->str) QSE_AWK_FREE (awk, nde->str); if (nde->str) qse_awk_freemem (awk, nde->str);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
@ -4492,8 +4491,8 @@ static qse_awk_nde_t* parse_primary_str (qse_awk_t* awk, const qse_awk_loc_t* x
oops: oops:
QSE_ASSERT (nde != QSE_NULL); QSE_ASSERT (nde != QSE_NULL);
if (nde->ptr) QSE_AWK_FREE (awk, nde->ptr); if (nde->ptr) qse_awk_freemem (awk, nde->ptr);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
@ -4538,8 +4537,8 @@ static qse_awk_nde_t* parse_primary_mbs (qse_awk_t* awk, const qse_awk_loc_t* xl
oops: oops:
QSE_ASSERT (nde != QSE_NULL); QSE_ASSERT (nde != QSE_NULL);
if (nde->ptr) QSE_AWK_FREE (awk, nde->ptr); if (nde->ptr) qse_awk_freemem (awk, nde->ptr);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
@ -4592,8 +4591,8 @@ static qse_awk_nde_t* parse_primary_rex (qse_awk_t* awk, const qse_awk_loc_t* xl
oops: oops:
QSE_ASSERT (nde != QSE_NULL); QSE_ASSERT (nde != QSE_NULL);
if (nde->code[0]) qse_awk_freerex (awk, nde->code[0], nde->code[1]); if (nde->code[0]) qse_awk_freerex (awk, nde->code[0], nde->code[1]);
if (nde->str.ptr) QSE_AWK_FREE (awk, nde->str.ptr); if (nde->str.ptr) qse_awk_freemem (awk, nde->str.ptr);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
return QSE_NULL; return QSE_NULL;
} }
@ -4624,7 +4623,7 @@ oops:
if (nde) if (nde)
{ {
if (nde->val) qse_awk_clrpt (awk, nde->val); if (nde->val) qse_awk_clrpt (awk, nde->val);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
} }
return QSE_NULL; return QSE_NULL;
} }
@ -4809,7 +4808,7 @@ oops:
{ {
if (nde->in) qse_awk_clrpt (awk, nde->in); if (nde->in) qse_awk_clrpt (awk, nde->in);
if (nde->var) qse_awk_clrpt (awk, nde->var); if (nde->var) qse_awk_clrpt (awk, nde->var);
QSE_AWK_FREE (awk, nde); qse_awk_freemem (awk, nde);
} }
return QSE_NULL; return QSE_NULL;
} }
@ -5258,7 +5257,7 @@ static qse_awk_nde_t* parse_primary_ident_noseg (qse_awk_t* awk, const qse_awk_l
if (qse_htb_upsert(awk->parse.named, name->ptr, name->len, QSE_NULL, 0) == QSE_NULL) if (qse_htb_upsert(awk->parse.named, name->ptr, name->len, QSE_NULL, 0) == QSE_NULL)
{ {
SETERR_LOC (awk, QSE_AWK_ENOMEM, xloc); SETERR_LOC (awk, QSE_AWK_ENOMEM, xloc);
QSE_AWK_FREE (awk, tmp); qse_awk_freemem (awk, tmp);
} }
else else
{ {

View File

@ -145,7 +145,7 @@ static int split_record (qse_awk_rtx_t* rtx)
QSE_STR_LEN(&rtx->inrec.line)) == (qse_size_t)-1) QSE_STR_LEN(&rtx->inrec.line)) == (qse_size_t)-1)
{ {
if (fs_free != QSE_NULL) if (fs_free != QSE_NULL)
QSE_AWK_FREE (rtx->awk, fs_free); qse_awk_rtx_freemem (rtx, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1; return -1;
} }
@ -187,7 +187,7 @@ static int split_record (qse_awk_rtx_t* rtx)
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR) if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{ {
if (fs_free != QSE_NULL) if (fs_free != QSE_NULL)
QSE_AWK_FREE (rtx->awk, fs_free); qse_awk_rtx_freemem (rtx, fs_free);
qse_awk_rtx_seterrnum (rtx, errnum, QSE_NULL); qse_awk_rtx_seterrnum (rtx, errnum, QSE_NULL);
return -1; return -1;
} }
@ -197,31 +197,27 @@ static int split_record (qse_awk_rtx_t* rtx)
{ {
/* there are no fields. it can just return here /* there are no fields. it can just return here
* as qse_awk_rtx_clrrec has been called before this */ * as qse_awk_rtx_clrrec has been called before this */
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
return 0; return 0;
} }
QSE_ASSERT ((tok.ptr != QSE_NULL && tok.len > 0) || tok.len == 0); QSE_ASSERT ((tok.ptr != QSE_NULL && tok.len > 0) || tok.len == 0);
nflds++; nflds++;
len = QSE_STR_LEN(&rtx->inrec.line) - len = QSE_STR_LEN(&rtx->inrec.line) - (p - QSE_STR_PTR(&rtx->inrec.line));
(p - QSE_STR_PTR(&rtx->inrec.line));
} }
/* allocate space */ /* allocate space */
if (nflds > rtx->inrec.maxflds) if (nflds > rtx->inrec.maxflds)
{ {
void* tmp = QSE_AWK_ALLOC ( void* tmp = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*rtx->inrec.flds) * nflds);
rtx->awk, QSE_SIZEOF(*rtx->inrec.flds) * nflds); if (!tmp)
if (tmp == QSE_NULL)
{ {
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1; return -1;
} }
if (rtx->inrec.flds != QSE_NULL) if (rtx->inrec.flds) qse_awk_rtx_freemem (rtx, rtx->inrec.flds);
QSE_AWK_FREE (rtx->awk, rtx->inrec.flds);
rtx->inrec.flds = tmp; rtx->inrec.flds = tmp;
rtx->inrec.maxflds = nflds; rtx->inrec.maxflds = nflds;
} }
@ -234,8 +230,7 @@ static int split_record (qse_awk_rtx_t* rtx)
QSE_STR_PTR(&rtx->inrec.line), QSE_STR_PTR(&rtx->inrec.line),
QSE_STR_LEN(&rtx->inrec.line)) == (qse_size_t)-1) QSE_STR_LEN(&rtx->inrec.line)) == (qse_size_t)-1)
{ {
if (fs_free != QSE_NULL) if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
QSE_AWK_FREE (rtx->awk, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL); qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1; return -1;
} }
@ -280,7 +275,7 @@ static int split_record (qse_awk_rtx_t* rtx)
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR) if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{ {
if (fs_free != QSE_NULL) if (fs_free != QSE_NULL)
QSE_AWK_FREE (rtx->awk, fs_free); qse_awk_rtx_freemem (rtx, fs_free);
qse_awk_rtx_seterrnum (rtx, errnum, QSE_NULL); qse_awk_rtx_seterrnum (rtx, errnum, QSE_NULL);
return -1; return -1;
} }
@ -291,7 +286,7 @@ static int split_record (qse_awk_rtx_t* rtx)
{ {
/* there are no fields. it can just return here /* there are no fields. it can just return here
* as qse_awk_rtx_clrrec has been called before this */ * as qse_awk_rtx_clrrec has been called before this */
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
return 0; return 0;
} }
#endif #endif
@ -306,22 +301,17 @@ static int split_record (qse_awk_rtx_t* rtx)
if (rtx->inrec.nflds < 16) nflds = 32; if (rtx->inrec.nflds < 16) nflds = 32;
else nflds = rtx->inrec.nflds * 2; else nflds = rtx->inrec.nflds * 2;
tmp = QSE_AWK_ALLOC ( tmp = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*rtx->inrec.flds) * nflds);
rtx->awk,
QSE_SIZEOF(*rtx->inrec.flds) * nflds
);
if (tmp == QSE_NULL) if (tmp == QSE_NULL)
{ {
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1; return -1;
} }
if (rtx->inrec.flds != QSE_NULL) if (rtx->inrec.flds != QSE_NULL)
{ {
QSE_MEMCPY (tmp, rtx->inrec.flds, QSE_MEMCPY (tmp, rtx->inrec.flds, QSE_SIZEOF(*rtx->inrec.flds) * rtx->inrec.nflds);
QSE_SIZEOF(*rtx->inrec.flds) * rtx->inrec.nflds); qse_awk_rtx_freemem (rtx, rtx->inrec.flds);
QSE_AWK_FREE (rtx->awk, rtx->inrec.flds);
} }
rtx->inrec.flds = tmp; rtx->inrec.flds = tmp;
@ -335,30 +325,28 @@ static int split_record (qse_awk_rtx_t* rtx)
if (rtx->inrec.flds[rtx->inrec.nflds].val == QSE_NULL) if (rtx->inrec.flds[rtx->inrec.nflds].val == QSE_NULL)
{ {
if (fs_free) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
return -1; return -1;
} }
qse_awk_rtx_refupval ( qse_awk_rtx_refupval (rtx, rtx->inrec.flds[rtx->inrec.nflds].val);
rtx, rtx->inrec.flds[rtx->inrec.nflds].val);
rtx->inrec.nflds++; rtx->inrec.nflds++;
len = QSE_STR_LEN(&rtx->inrec.line) - (p - px); len = QSE_STR_LEN(&rtx->inrec.line) - (p - px);
} }
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free); if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
/* set the number of fields */ /* set the number of fields */
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)rtx->inrec.nflds); v = qse_awk_rtx_makeintval(rtx, (qse_awk_int_t)rtx->inrec.nflds);
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
qse_awk_rtx_refupval (rtx, v); qse_awk_rtx_refupval (rtx, v);
if (qse_awk_rtx_setgbl (rtx, QSE_AWK_GBL_NF, v) == -1) if (qse_awk_rtx_setgbl(rtx, QSE_AWK_GBL_NF, v) == -1)
{ {
qse_awk_rtx_refdownval (rtx, v); qse_awk_rtx_refdownval (rtx, v);
return -1; return -1;
} }
qse_awk_rtx_refdownval (rtx, v); qse_awk_rtx_refdownval (rtx, v);
return 0; return 0;
} }
@ -401,8 +389,7 @@ int qse_awk_rtx_clrrec (qse_awk_rtx_t* run, int skip_inrec_line)
return n; return n;
} }
static int recomp_record_fields ( static int recomp_record_fields (qse_awk_rtx_t* run, qse_size_t lv, const qse_cstr_t* str)
qse_awk_rtx_t* run, qse_size_t lv, const qse_cstr_t* str)
{ {
qse_awk_val_t* v; qse_awk_val_t* v;
qse_size_t max, i, nflds; qse_size_t max, i, nflds;
@ -422,14 +409,8 @@ static int recomp_record_fields (
* number of fields that the current record can hold, * number of fields that the current record can hold,
* the field spaces are resized */ * the field spaces are resized */
tmp = QSE_AWK_REALLOC ( tmp = qse_awk_rtx_reallocmem(run, run->inrec.flds, QSE_SIZEOF(*run->inrec.flds) * max);
run->awk, run->inrec.flds, if (!tmp == QSE_NULL) return -1;
QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
run->inrec.flds = tmp; run->inrec.flds = tmp;
run->inrec.maxflds = max; run->inrec.maxflds = max;

File diff suppressed because it is too large Load Diff

View File

@ -1219,14 +1219,14 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
case QSE_AWK_NDE_NULL: case QSE_AWK_NDE_NULL:
{ {
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_BLK: case QSE_AWK_NDE_BLK:
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_blk_t*)p)->body); qse_awk_clrpt (awk, ((qse_awk_nde_blk_t*)p)->body);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1236,7 +1236,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_clrpt (awk, px->test); qse_awk_clrpt (awk, px->test);
qse_awk_clrpt (awk, px->then_part); qse_awk_clrpt (awk, px->then_part);
if (px->else_part) qse_awk_clrpt (awk, px->else_part); if (px->else_part) qse_awk_clrpt (awk, px->else_part);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1245,7 +1245,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_while_t*)p)->test); qse_awk_clrpt (awk, ((qse_awk_nde_while_t*)p)->test);
qse_awk_clrpt (awk, ((qse_awk_nde_while_t*)p)->body); qse_awk_clrpt (awk, ((qse_awk_nde_while_t*)p)->body);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1256,7 +1256,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
if (px->test) qse_awk_clrpt (awk, px->test); if (px->test) qse_awk_clrpt (awk, px->test);
if (px->incr) qse_awk_clrpt (awk, px->incr); if (px->incr) qse_awk_clrpt (awk, px->incr);
qse_awk_clrpt (awk, px->body); qse_awk_clrpt (awk, px->body);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1264,19 +1264,19 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_foreach_t*)p)->test); qse_awk_clrpt (awk, ((qse_awk_nde_foreach_t*)p)->test);
qse_awk_clrpt (awk, ((qse_awk_nde_foreach_t*)p)->body); qse_awk_clrpt (awk, ((qse_awk_nde_foreach_t*)p)->body);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_BREAK: case QSE_AWK_NDE_BREAK:
{ {
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_CONTINUE: case QSE_AWK_NDE_CONTINUE:
{ {
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1284,7 +1284,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_nde_return_t* px = (qse_awk_nde_return_t*)p; qse_awk_nde_return_t* px = (qse_awk_nde_return_t*)p;
if (px->val) qse_awk_clrpt (awk, px->val); if (px->val) qse_awk_clrpt (awk, px->val);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1292,28 +1292,28 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
if (((qse_awk_nde_exit_t*)p)->val != QSE_NULL) if (((qse_awk_nde_exit_t*)p)->val != QSE_NULL)
qse_awk_clrpt (awk, ((qse_awk_nde_exit_t*)p)->val); qse_awk_clrpt (awk, ((qse_awk_nde_exit_t*)p)->val);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_NEXT: case QSE_AWK_NDE_NEXT:
case QSE_AWK_NDE_NEXTFILE: case QSE_AWK_NDE_NEXTFILE:
{ {
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_DELETE: case QSE_AWK_NDE_DELETE:
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_delete_t*)p)->var); qse_awk_clrpt (awk, ((qse_awk_nde_delete_t*)p)->var);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_RESET: case QSE_AWK_NDE_RESET:
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_reset_t*)p)->var); qse_awk_clrpt (awk, ((qse_awk_nde_reset_t*)p)->var);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1323,14 +1323,14 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_nde_print_t* px = (qse_awk_nde_print_t*)p; qse_awk_nde_print_t* px = (qse_awk_nde_print_t*)p;
if (px->args) qse_awk_clrpt (awk, px->args); if (px->args) qse_awk_clrpt (awk, px->args);
if (px->out) qse_awk_clrpt (awk, px->out); if (px->out) qse_awk_clrpt (awk, px->out);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_GRP: case QSE_AWK_NDE_GRP:
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_grp_t*)p)->body); qse_awk_clrpt (awk, ((qse_awk_nde_grp_t*)p)->body);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1338,7 +1338,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_ass_t*)p)->left); qse_awk_clrpt (awk, ((qse_awk_nde_ass_t*)p)->left);
qse_awk_clrpt (awk, ((qse_awk_nde_ass_t*)p)->right); qse_awk_clrpt (awk, ((qse_awk_nde_ass_t*)p)->right);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1350,7 +1350,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_clrpt (awk, px->left); qse_awk_clrpt (awk, px->left);
qse_awk_clrpt (awk, px->right); qse_awk_clrpt (awk, px->right);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1361,7 +1361,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_nde_exp_t* px = (qse_awk_nde_exp_t*)p; qse_awk_nde_exp_t* px = (qse_awk_nde_exp_t*)p;
QSE_ASSERT (px->right == QSE_NULL); QSE_ASSERT (px->right == QSE_NULL);
qse_awk_clrpt (awk, px->left); qse_awk_clrpt (awk, px->left);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1370,37 +1370,37 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->test); qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->test);
qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->left); qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->left);
qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->right); qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->right);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_INT: case QSE_AWK_NDE_INT:
{ {
if (((qse_awk_nde_int_t*)p)->str) if (((qse_awk_nde_int_t*)p)->str)
QSE_AWK_FREE (awk, ((qse_awk_nde_int_t*)p)->str); qse_awk_freemem (awk, ((qse_awk_nde_int_t*)p)->str);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_FLT: case QSE_AWK_NDE_FLT:
{ {
if (((qse_awk_nde_flt_t*)p)->str) if (((qse_awk_nde_flt_t*)p)->str)
QSE_AWK_FREE (awk, ((qse_awk_nde_flt_t*)p)->str); qse_awk_freemem (awk, ((qse_awk_nde_flt_t*)p)->str);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_STR: case QSE_AWK_NDE_STR:
{ {
QSE_AWK_FREE (awk, ((qse_awk_nde_str_t*)p)->ptr); qse_awk_freemem (awk, ((qse_awk_nde_str_t*)p)->ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_MBS: case QSE_AWK_NDE_MBS:
{ {
QSE_AWK_FREE (awk, ((qse_awk_nde_mbs_t*)p)->ptr); qse_awk_freemem (awk, ((qse_awk_nde_mbs_t*)p)->ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1408,15 +1408,15 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_nde_rex_t* rex = (qse_awk_nde_rex_t*)p; qse_awk_nde_rex_t* rex = (qse_awk_nde_rex_t*)p;
qse_awk_freerex (awk, rex->code[0], rex->code[1]); qse_awk_freerex (awk, rex->code[0], rex->code[1]);
QSE_AWK_FREE (awk, ((qse_awk_nde_rex_t*)p)->str.ptr); qse_awk_freemem (awk, ((qse_awk_nde_rex_t*)p)->str.ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_FUN: case QSE_AWK_NDE_FUN:
{ {
QSE_AWK_FREE (awk, ((qse_awk_nde_fun_t*)p)->name.ptr); qse_awk_freemem (awk, ((qse_awk_nde_fun_t*)p)->name.ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1427,8 +1427,8 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
{ {
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p;
QSE_ASSERT (px->idx == QSE_NULL); QSE_ASSERT (px->idx == QSE_NULL);
if (px->id.name.ptr) QSE_AWK_FREE (awk, px->id.name.ptr); if (px->id.name.ptr) qse_awk_freemem (awk, px->id.name.ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1440,34 +1440,34 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p;
QSE_ASSERT (px->idx != QSE_NULL); QSE_ASSERT (px->idx != QSE_NULL);
qse_awk_clrpt (awk, px->idx); qse_awk_clrpt (awk, px->idx);
if (px->id.name.ptr) QSE_AWK_FREE (awk, px->id.name.ptr); if (px->id.name.ptr) qse_awk_freemem (awk, px->id.name.ptr);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_POS: case QSE_AWK_NDE_POS:
{ {
qse_awk_clrpt (awk, ((qse_awk_nde_pos_t*)p)->val); qse_awk_clrpt (awk, ((qse_awk_nde_pos_t*)p)->val);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_FNCALL_FNC: case QSE_AWK_NDE_FNCALL_FNC:
{ {
qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p; qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p;
/* QSE_AWK_FREE (awk, px->u.fnc); */ /* qse_awk_freemem (awk, px->u.fnc); */
QSE_AWK_FREE (awk, px->u.fnc.info.name.ptr); qse_awk_freemem (awk, px->u.fnc.info.name.ptr);
qse_awk_clrpt (awk, px->args); qse_awk_clrpt (awk, px->args);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
case QSE_AWK_NDE_FNCALL_FUN: case QSE_AWK_NDE_FNCALL_FUN:
{ {
qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p; qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p;
QSE_AWK_FREE (awk, px->u.fun.name.ptr); qse_awk_freemem (awk, px->u.fun.name.ptr);
qse_awk_clrpt (awk, px->args); qse_awk_clrpt (awk, px->args);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1476,7 +1476,7 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p; qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p;
qse_awk_clrpt (awk, (qse_awk_nde_t*)px->u.var.var); qse_awk_clrpt (awk, (qse_awk_nde_t*)px->u.var.var);
qse_awk_clrpt (awk, px->args); qse_awk_clrpt (awk, px->args);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
@ -1485,14 +1485,14 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
qse_awk_nde_getline_t* px = (qse_awk_nde_getline_t*)p; qse_awk_nde_getline_t* px = (qse_awk_nde_getline_t*)p;
if (px->var) qse_awk_clrpt (awk, px->var); if (px->var) qse_awk_clrpt (awk, px->var);
if (px->in) qse_awk_clrpt (awk, px->in); if (px->in) qse_awk_clrpt (awk, px->in);
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
default: default:
{ {
QSE_ASSERT (!"should never happen - invalid node type"); QSE_ASSERT (!"should never happen - invalid node type");
QSE_AWK_FREE (awk, p); qse_awk_freemem (awk, p);
break; break;
} }
} }

View File

@ -220,7 +220,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithmbs (qse_awk_rtx_t* rtx, const qse_mcha
} }
v = qse_awk_rtx_makestrvalwithxstr (rtx, &tmp); v = qse_awk_rtx_makestrvalwithxstr (rtx, &tmp);
QSE_AWK_FREE (rtx->awk, tmp.ptr); qse_awk_rtx_freemem (rtx, tmp.ptr);
return v; return v;
#endif #endif
} }
@ -239,7 +239,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithwcs (qse_awk_rtx_t* rtx, const qse_wcha
} }
v = qse_awk_rtx_makestrvalwithxstr (rtx, &tmp); v = qse_awk_rtx_makestrvalwithxstr (rtx, &tmp);
QSE_AWK_FREE (rtx->awk, tmp.ptr); qse_awk_rtx_freemem (rtx, tmp.ptr);
return v; return v;
#else #else
return qse_awk_rtx_makestrval (rtx, wcs, qse_wcslen(wcs)); return qse_awk_rtx_makestrval (rtx, wcs, qse_wcslen(wcs));
@ -269,7 +269,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithmxstr (qse_awk_rtx_t* rtx, const qse_mc
} }
v = qse_awk_rtx_makestrvalwithxstr(rtx, &tmp); v = qse_awk_rtx_makestrvalwithxstr(rtx, &tmp);
QSE_AWK_FREE (rtx->awk, tmp.ptr); qse_awk_rtx_freemem (rtx, tmp.ptr);
return v; return v;
#endif #endif
} }
@ -290,7 +290,7 @@ qse_awk_val_t* qse_awk_rtx_makestrvalwithwxstr (qse_awk_rtx_t* rtx, const qse_wc
} }
v = qse_awk_rtx_makestrvalwithxstr(rtx, &tmp); v = qse_awk_rtx_makestrvalwithxstr(rtx, &tmp);
QSE_AWK_FREE (rtx->awk, tmp.ptr); qse_awk_rtx_freemem (rtx, tmp.ptr);
return v; return v;
#else #else
return qse_awk_rtx_makestrvalwithxstr(rtx, wxstr); return qse_awk_rtx_makestrvalwithxstr(rtx, wxstr);
@ -745,7 +745,7 @@ void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
{ {
case QSE_AWK_VAL_NIL: case QSE_AWK_VAL_NIL:
{ {
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
} }
@ -778,23 +778,23 @@ void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
rtx->scache[i][rtx->scache_count[i]++] = v; rtx->scache[i][rtx->scache_count[i]++] = v;
v->nstr = 0; v->nstr = 0;
} }
else QSE_AWK_FREE (rtx->awk, val); else qse_awk_rtx_freemem (rtx, val);
} }
else else
#endif #endif
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
} }
case QSE_AWK_VAL_MBS: case QSE_AWK_VAL_MBS:
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
case QSE_AWK_VAL_REX: case QSE_AWK_VAL_REX:
{ {
/* don't free ptr as it is inlined to val /* don't free ptr as it is inlined to val
QSE_AWK_FREE (rtx->awk, ((qse_awk_val_rex_t*)val)->ptr); qse_awk_rtx_freemem (rtx, ((qse_awk_val_rex_t*)val)->ptr);
*/ */
/* code is just a pointer to a regular expression stored /* code is just a pointer to a regular expression stored
@ -802,18 +802,18 @@ void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
qse_awk_freerex (rtx->awk, ((qse_awk_val_rex_t*)val)->code[0], ((qse_awk_val_rex_t*)val)->code[1]); qse_awk_freerex (rtx->awk, ((qse_awk_val_rex_t*)val)->code[0], ((qse_awk_val_rex_t*)val)->code[1]);
*/ */
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
} }
case QSE_AWK_VAL_FUN: case QSE_AWK_VAL_FUN:
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
case QSE_AWK_VAL_MAP: case QSE_AWK_VAL_MAP:
{ {
qse_htb_fini (((qse_awk_val_map_t*)val)->map); qse_htb_fini (((qse_awk_val_map_t*)val)->map);
QSE_AWK_FREE (rtx->awk, val); qse_awk_rtx_freemem (rtx, val);
break; break;
} }
@ -823,7 +823,7 @@ void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
{ {
rtx->rcache[rtx->rcache_count++] = (qse_awk_val_ref_t*)val; rtx->rcache[rtx->rcache_count++] = (qse_awk_val_ref_t*)val;
} }
else QSE_AWK_FREE (rtx->awk, val); else qse_awk_rtx_freemem (rtx, val);
break; break;
} }
@ -887,7 +887,7 @@ void qse_awk_rtx_freevalchunk (qse_awk_rtx_t* rtx, qse_awk_val_chunk_t* chunk)
while (chunk != QSE_NULL) while (chunk != QSE_NULL)
{ {
qse_awk_val_chunk_t* next = chunk->next; qse_awk_val_chunk_t* next = chunk->next;
QSE_AWK_FREE (rtx->awk, chunk); qse_awk_rtx_freemem (rtx, chunk);
chunk = next; chunk = next;
} }
} }
@ -2048,7 +2048,7 @@ int qse_awk_rtx_setrefval (qse_awk_rtx_t* rtx, qse_awk_val_ref_t* ref, qse_awk_v
qse_awk_rtx_refupval (rtx, val); qse_awk_rtx_refupval (rtx, val);
x = qse_awk_rtx_setrec(rtx, (qse_size_t)ref->adr, &str); x = qse_awk_rtx_setrec(rtx, (qse_size_t)ref->adr, &str);
qse_awk_rtx_refdownval (rtx, val); qse_awk_rtx_refdownval (rtx, val);
QSE_AWK_FREE (rtx->awk, str.ptr); qse_awk_rtx_freemem (rtx, str.ptr);
return x; return x;
} }
} }