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_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;
};
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;
/* 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_FREE (awk, f);
qse_awk_freemem (awk, f);
}
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_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)
@ -299,7 +299,7 @@ void qse_awk_fini (qse_awk_t* awk)
/* destroy dynamically allocated options */
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);
if (awk->tree.chain->action != QSE_NULL)
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;
}
@ -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;
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;
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;
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;
return 0;
}

View File

@ -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;
}
if (qse_htb_insert (awk->fnc.user,
(qse_char_t*)ncs.ptr, ncs.len, fnc, 0) == QSE_NULL)
if (qse_htb_insert(awk->fnc.user, (qse_char_t*)ncs.ptr, ncs.len, fnc, 0) == 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;
}
}
@ -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().
if (n <= -1 && rtx->errinf.num != QSE_AWK_EIONMNF)
{
if (a0->type != QSE_AWK_VAL_STR)
QSE_AWK_FREE (rtx->awk, name);
if (a0->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, name);
return -1;
}
*/
@ -601,13 +600,13 @@ int qse_awk_fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
default:
/* convert to string and get length */
str = qse_awk_rtx_valtostrdup(rtx, v, &len);
if (str == QSE_NULL) return -1;
QSE_AWK_FREE (rtx->awk, str);
if (!str) return -1;
qse_awk_rtx_freemem (rtx, str);
}
}
v = qse_awk_rtx_makeintval(rtx, len);
if (v == QSE_NULL) return -1;
if (!v) return -1;
qse_awk_rtx_setretval (rtx, v);
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);
}
/*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);
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;
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 (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);
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);
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);
if (v == QSE_NULL) return -1;
@ -1203,9 +1202,9 @@ oops:
qse_awk_freerex (rtx->awk, rex_free, QSE_NULL);
}
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 (s0_free) QSE_AWK_FREE (rtx->awk, s0_free);
if (s0_free) qse_awk_rtx_freemem (rtx, s0_free);
return -1;
}

View File

@ -622,7 +622,7 @@ oops:
prev = awk->sio.inp->prev;
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;
}
@ -634,8 +634,7 @@ oops:
CLRERR (awk);
}
if (awk->sio.inf (
awk, QSE_AWK_SIO_CLOSE, awk->sio.inp, QSE_NULL, 0) != 0)
if (awk->sio.inf(awk, QSE_AWK_SIO_CLOSE, awk->sio.inp, QSE_NULL, 0) != 0)
{
if (ret == 0)
{
@ -663,7 +662,7 @@ void qse_awk_clearsionames (qse_awk_t* awk)
{
cur = awk->sio_names;
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);
if (val == QSE_NULL)
{
QSE_AWK_FREE (awk, nde);
qse_awk_freemem (awk, nde);
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);
if (val == QSE_NULL)
{
QSE_AWK_FREE (awk, nde);
qse_awk_freemem (awk, nde);
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_type = tab[i].out;
QSE_AWK_FREE (awk, tmp);
qse_awk_freemem (awk, tmp);
break;
}
}
@ -3672,7 +3671,7 @@ static QSE_INLINE void update_int_node (
node->val = lv;
if (node->str)
{
QSE_AWK_FREE (awk, node->str);
qse_awk_freemem (awk, node->str);
node->str = QSE_NULL;
node->len = 0;
}
@ -3684,7 +3683,7 @@ static QSE_INLINE void update_flt_node (
node->val = rv;
if (node->str)
{
QSE_AWK_FREE (awk, node->str);
qse_awk_freemem (awk, node->str);
node->str = QSE_NULL;
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:
QSE_ASSERT (nde != QSE_NULL);
if (nde->str) QSE_AWK_FREE (awk, nde->str);
QSE_AWK_FREE (awk, nde);
if (nde->str) qse_awk_freemem (awk, nde->str);
qse_awk_freemem (awk, nde);
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:
QSE_ASSERT (nde != QSE_NULL);
if (nde->str) QSE_AWK_FREE (awk, nde->str);
QSE_AWK_FREE (awk, nde);
if (nde->str) qse_awk_freemem (awk, nde->str);
qse_awk_freemem (awk, nde);
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:
QSE_ASSERT (nde != QSE_NULL);
if (nde->ptr) QSE_AWK_FREE (awk, nde->ptr);
QSE_AWK_FREE (awk, nde);
if (nde->ptr) qse_awk_freemem (awk, nde->ptr);
qse_awk_freemem (awk, nde);
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:
QSE_ASSERT (nde != QSE_NULL);
if (nde->ptr) QSE_AWK_FREE (awk, nde->ptr);
QSE_AWK_FREE (awk, nde);
if (nde->ptr) qse_awk_freemem (awk, nde->ptr);
qse_awk_freemem (awk, nde);
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:
QSE_ASSERT (nde != QSE_NULL);
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);
QSE_AWK_FREE (awk, nde);
if (nde->str.ptr) qse_awk_freemem (awk, nde->str.ptr);
qse_awk_freemem (awk, nde);
return QSE_NULL;
}
@ -4624,7 +4623,7 @@ oops:
if (nde)
{
if (nde->val) qse_awk_clrpt (awk, nde->val);
QSE_AWK_FREE (awk, nde);
qse_awk_freemem (awk, nde);
}
return QSE_NULL;
}
@ -4809,7 +4808,7 @@ oops:
{
if (nde->in) qse_awk_clrpt (awk, nde->in);
if (nde->var) qse_awk_clrpt (awk, nde->var);
QSE_AWK_FREE (awk, nde);
qse_awk_freemem (awk, nde);
}
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)
{
SETERR_LOC (awk, QSE_AWK_ENOMEM, xloc);
QSE_AWK_FREE (awk, tmp);
qse_awk_freemem (awk, tmp);
}
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)
{
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);
return -1;
}
@ -187,7 +187,7 @@ static int split_record (qse_awk_rtx_t* rtx)
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{
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);
return -1;
}
@ -197,31 +197,27 @@ static int split_record (qse_awk_rtx_t* rtx)
{
/* there are no fields. it can just return here
* 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;
}
QSE_ASSERT ((tok.ptr != QSE_NULL && tok.len > 0) || tok.len == 0);
nflds++;
len = QSE_STR_LEN(&rtx->inrec.line) -
(p - QSE_STR_PTR(&rtx->inrec.line));
len = QSE_STR_LEN(&rtx->inrec.line) - (p - QSE_STR_PTR(&rtx->inrec.line));
}
/* allocate space */
if (nflds > rtx->inrec.maxflds)
{
void* tmp = QSE_AWK_ALLOC (
rtx->awk, QSE_SIZEOF(*rtx->inrec.flds) * nflds);
if (tmp == QSE_NULL)
void* tmp = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*rtx->inrec.flds) * nflds);
if (!tmp)
{
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
return -1;
}
if (rtx->inrec.flds != QSE_NULL)
QSE_AWK_FREE (rtx->awk, rtx->inrec.flds);
if (rtx->inrec.flds) qse_awk_rtx_freemem (rtx, rtx->inrec.flds);
rtx->inrec.flds = tmp;
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_LEN(&rtx->inrec.line)) == (qse_size_t)-1)
{
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;
}
@ -280,7 +275,7 @@ static int split_record (qse_awk_rtx_t* rtx)
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{
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);
return -1;
}
@ -291,7 +286,7 @@ static int split_record (qse_awk_rtx_t* rtx)
{
/* there are no fields. it can just return here
* 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;
}
#endif
@ -306,22 +301,17 @@ static int split_record (qse_awk_rtx_t* rtx)
if (rtx->inrec.nflds < 16) nflds = 32;
else nflds = rtx->inrec.nflds * 2;
tmp = QSE_AWK_ALLOC (
rtx->awk,
QSE_SIZEOF(*rtx->inrec.flds) * nflds
);
tmp = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*rtx->inrec.flds) * nflds);
if (tmp == QSE_NULL)
{
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
if (fs_free) qse_awk_rtx_freemem (rtx, fs_free);
return -1;
}
if (rtx->inrec.flds != QSE_NULL)
{
QSE_MEMCPY (tmp, rtx->inrec.flds,
QSE_SIZEOF(*rtx->inrec.flds) * rtx->inrec.nflds);
QSE_AWK_FREE (rtx->awk, rtx->inrec.flds);
QSE_MEMCPY (tmp, rtx->inrec.flds, QSE_SIZEOF(*rtx->inrec.flds) * rtx->inrec.nflds);
qse_awk_rtx_freemem (rtx, rtx->inrec.flds);
}
rtx->inrec.flds = tmp;
@ -335,18 +325,17 @@ static int split_record (qse_awk_rtx_t* rtx)
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;
}
qse_awk_rtx_refupval (
rtx, rtx->inrec.flds[rtx->inrec.nflds].val);
qse_awk_rtx_refupval (rtx, rtx->inrec.flds[rtx->inrec.nflds].val);
rtx->inrec.nflds++;
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 */
v = qse_awk_rtx_makeintval(rtx, (qse_awk_int_t)rtx->inrec.nflds);
@ -358,7 +347,6 @@ static int split_record (qse_awk_rtx_t* rtx)
qse_awk_rtx_refdownval (rtx, v);
return -1;
}
qse_awk_rtx_refdownval (rtx, v);
return 0;
}
@ -401,8 +389,7 @@ int qse_awk_rtx_clrrec (qse_awk_rtx_t* run, int skip_inrec_line)
return n;
}
static int recomp_record_fields (
qse_awk_rtx_t* run, qse_size_t lv, const qse_cstr_t* str)
static int recomp_record_fields (qse_awk_rtx_t* run, qse_size_t lv, const qse_cstr_t* str)
{
qse_awk_val_t* v;
qse_size_t max, i, nflds;
@ -422,14 +409,8 @@ static int recomp_record_fields (
* number of fields that the current record can hold,
* the field spaces are resized */
tmp = QSE_AWK_REALLOC (
run->awk, run->inrec.flds,
QSE_SIZEOF(*run->inrec.flds) * max);
if (tmp == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
tmp = qse_awk_rtx_reallocmem(run, run->inrec.flds, QSE_SIZEOF(*run->inrec.flds) * max);
if (!tmp == QSE_NULL) return -1;
run->inrec.flds = tmp;
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:
{
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_BLK:
{
qse_awk_clrpt (awk, ((qse_awk_nde_blk_t*)p)->body);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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->then_part);
if (px->else_part) qse_awk_clrpt (awk, px->else_part);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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)->body);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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->incr) qse_awk_clrpt (awk, px->incr);
qse_awk_clrpt (awk, px->body);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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)->body);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_BREAK:
{
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_CONTINUE:
{
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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;
if (px->val) qse_awk_clrpt (awk, px->val);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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)
qse_awk_clrpt (awk, ((qse_awk_nde_exit_t*)p)->val);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_NEXT:
case QSE_AWK_NDE_NEXTFILE:
{
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_DELETE:
{
qse_awk_clrpt (awk, ((qse_awk_nde_delete_t*)p)->var);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_RESET:
{
qse_awk_clrpt (awk, ((qse_awk_nde_reset_t*)p)->var);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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;
if (px->args) qse_awk_clrpt (awk, px->args);
if (px->out) qse_awk_clrpt (awk, px->out);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_GRP:
{
qse_awk_clrpt (awk, ((qse_awk_nde_grp_t*)p)->body);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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)->right);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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->right);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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_ASSERT (px->right == QSE_NULL);
qse_awk_clrpt (awk, px->left);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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)->left);
qse_awk_clrpt (awk, ((qse_awk_nde_cnd_t*)p)->right);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_INT:
{
if (((qse_awk_nde_int_t*)p)->str)
QSE_AWK_FREE (awk, ((qse_awk_nde_int_t*)p)->str);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_int_t*)p)->str);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_FLT:
{
if (((qse_awk_nde_flt_t*)p)->str)
QSE_AWK_FREE (awk, ((qse_awk_nde_flt_t*)p)->str);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_flt_t*)p)->str);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_STR:
{
QSE_AWK_FREE (awk, ((qse_awk_nde_str_t*)p)->ptr);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_str_t*)p)->ptr);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_MBS:
{
QSE_AWK_FREE (awk, ((qse_awk_nde_mbs_t*)p)->ptr);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_mbs_t*)p)->ptr);
qse_awk_freemem (awk, p);
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_freerex (awk, rex->code[0], rex->code[1]);
QSE_AWK_FREE (awk, ((qse_awk_nde_rex_t*)p)->str.ptr);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_rex_t*)p)->str.ptr);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_FUN:
{
QSE_AWK_FREE (awk, ((qse_awk_nde_fun_t*)p)->name.ptr);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, ((qse_awk_nde_fun_t*)p)->name.ptr);
qse_awk_freemem (awk, p);
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_ASSERT (px->idx == QSE_NULL);
if (px->id.name.ptr) QSE_AWK_FREE (awk, px->id.name.ptr);
QSE_AWK_FREE (awk, p);
if (px->id.name.ptr) qse_awk_freemem (awk, px->id.name.ptr);
qse_awk_freemem (awk, p);
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_ASSERT (px->idx != QSE_NULL);
qse_awk_clrpt (awk, px->idx);
if (px->id.name.ptr) QSE_AWK_FREE (awk, px->id.name.ptr);
QSE_AWK_FREE (awk, p);
if (px->id.name.ptr) qse_awk_freemem (awk, px->id.name.ptr);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_POS:
{
qse_awk_clrpt (awk, ((qse_awk_nde_pos_t*)p)->val);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_FNCALL_FNC:
{
qse_awk_nde_fncall_t* px = (qse_awk_nde_fncall_t*)p;
/* QSE_AWK_FREE (awk, px->u.fnc); */
QSE_AWK_FREE (awk, px->u.fnc.info.name.ptr);
/* qse_awk_freemem (awk, px->u.fnc); */
qse_awk_freemem (awk, px->u.fnc.info.name.ptr);
qse_awk_clrpt (awk, px->args);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
case QSE_AWK_NDE_FNCALL_FUN:
{
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_FREE (awk, p);
qse_awk_freemem (awk, p);
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_clrpt (awk, (qse_awk_nde_t*)px->u.var.var);
qse_awk_clrpt (awk, px->args);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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;
if (px->var) qse_awk_clrpt (awk, px->var);
if (px->in) qse_awk_clrpt (awk, px->in);
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
break;
}
default:
{
QSE_ASSERT (!"should never happen - invalid node type");
QSE_AWK_FREE (awk, p);
qse_awk_freemem (awk, p);
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);
QSE_AWK_FREE (rtx->awk, tmp.ptr);
qse_awk_rtx_freemem (rtx, tmp.ptr);
return v;
#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);
QSE_AWK_FREE (rtx->awk, tmp.ptr);
qse_awk_rtx_freemem (rtx, tmp.ptr);
return v;
#else
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);
QSE_AWK_FREE (rtx->awk, tmp.ptr);
qse_awk_rtx_freemem (rtx, tmp.ptr);
return v;
#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);
QSE_AWK_FREE (rtx->awk, tmp.ptr);
qse_awk_rtx_freemem (rtx, tmp.ptr);
return v;
#else
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:
{
QSE_AWK_FREE (rtx->awk, val);
qse_awk_rtx_freemem (rtx, val);
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;
v->nstr = 0;
}
else QSE_AWK_FREE (rtx->awk, val);
else qse_awk_rtx_freemem (rtx, val);
}
else
#endif
QSE_AWK_FREE (rtx->awk, val);
qse_awk_rtx_freemem (rtx, val);
break;
}
case QSE_AWK_VAL_MBS:
QSE_AWK_FREE (rtx->awk, val);
qse_awk_rtx_freemem (rtx, val);
break;
case QSE_AWK_VAL_REX:
{
/* 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
@ -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_FREE (rtx->awk, val);
qse_awk_rtx_freemem (rtx, val);
break;
}
case QSE_AWK_VAL_FUN:
QSE_AWK_FREE (rtx->awk, val);
qse_awk_rtx_freemem (rtx, val);
break;
case QSE_AWK_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;
}
@ -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;
}
else QSE_AWK_FREE (rtx->awk, val);
else qse_awk_rtx_freemem (rtx, val);
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)
{
qse_awk_val_chunk_t* next = chunk->next;
QSE_AWK_FREE (rtx->awk, chunk);
qse_awk_rtx_freemem (rtx, chunk);
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);
x = qse_awk_rtx_setrec(rtx, (qse_size_t)ref->adr, &str);
qse_awk_rtx_refdownval (rtx, val);
QSE_AWK_FREE (rtx->awk, str.ptr);
qse_awk_rtx_freemem (rtx, str.ptr);
return x;
}
}