From bb7a22e049cc3595b7681f2b33552aa89c3bba37 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 21 Aug 2006 02:53:42 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk_i.h | 4 +++- ase/awk/run.c | 9 ++++++++- ase/awk/val.c | 22 ++++++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index a605de96..483dad8c 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.45 2006-08-16 09:35:21 bacon Exp $ + * $Id: awk_i.h,v 1.46 2006-08-21 02:53:42 bacon Exp $ */ #ifndef _XP_AWK_AWKI_H_ @@ -156,8 +156,10 @@ struct xp_awk_run_t xp_awk_val_int_t* icache[100]; /* TODO: choose the optimal size */ xp_awk_val_real_t* rcache[100]; /* TODO: choose the optimal size */ + xp_awk_val_ref_t* fcache[100]; /* TODO: choose the optimal size */ xp_size_t icache_count; xp_size_t rcache_count; + xp_size_t fcache_count; xp_awk_nde_blk_t* active_block; xp_byte_t* pattern_range_state; diff --git a/ase/awk/run.c b/ase/awk/run.c index 05c36271..3dbb7c3b 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.172 2006-08-20 15:49:06 bacon Exp $ + * $Id: run.c,v 1.173 2006-08-21 02:53:42 bacon Exp $ */ #include @@ -425,6 +425,7 @@ static int __init_run ( run->icache_count = 0; run->rcache_count = 0; + run->fcache_count = 0; run->errnum = XP_AWK_ENOERR; @@ -515,6 +516,12 @@ static void __deinit_run (xp_awk_run_t* run) xp_awk_val_real_t* tmp = run->rcache[--run->rcache_count]; xp_awk_freeval (run, (xp_awk_val_t*)tmp, xp_false); } + + while (run->fcache_count > 0) + { + xp_awk_val_ref_t* tmp = run->fcache[--run->fcache_count]; + xp_awk_freeval (run, (xp_awk_val_t*)tmp, xp_false); + } } static int __run_main (xp_awk_run_t* run) diff --git a/ase/awk/val.c b/ase/awk/val.c index 5e8fbc84..cbfe5eef 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.51 2006-08-20 15:49:07 bacon Exp $ + * $Id: val.c,v 1.52 2006-08-21 02:53:42 bacon Exp $ */ #include @@ -198,8 +198,16 @@ xp_awk_val_t* xp_awk_makerefval (xp_awk_run_t* run, int id, xp_awk_val_t** adr) { xp_awk_val_ref_t* val; - val = (xp_awk_val_ref_t*) xp_malloc (xp_sizeof(xp_awk_val_ref_t)); - if (val == XP_NULL) return XP_NULL; + if (run->fcache_count > 0) + { + val = run->fcache[--run->fcache_count]; + } + else + { + val = (xp_awk_val_ref_t*) + xp_malloc (xp_sizeof(xp_awk_val_ref_t)); + if (val == XP_NULL) return XP_NULL; + } val->type = XP_AWK_VAL_REF; val->ref = 0; @@ -267,7 +275,13 @@ xp_printf (XP_T("\n"));*/ } else if (val->type == XP_AWK_VAL_REF) { - xp_free (val); + if (cache == xp_true && + run->fcache_count < xp_countof(run->fcache)) + { + run->fcache[run->fcache_count++] = + (xp_awk_val_ref_t*)val; + } + else xp_free (val); } else {