This commit is contained in:
hyung-hwan 2008-03-23 00:47:27 +00:00
parent d7c9d78474
commit 3de3860163
4 changed files with 87 additions and 31 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c 152 2008-03-21 11:57:29Z baconevi $ * $Id: run.c 155 2008-03-22 06:47:27Z baconevi $
* *
* {License} * {License}
*/ */
@ -970,19 +970,10 @@ static void deinit_run (ase_awk_run_t* run)
ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false); ase_awk_freeval (run, (ase_awk_val_t*)tmp, ase_false);
}*/ }*/
while (run->vmgr.ichunk != ASE_NULL) ase_awk_freevalchunk (run, run->vmgr.ichunk);
{ ase_awk_freevalchunk (run, run->vmgr.rchunk);
ase_awk_val_chunk_t* next = run->vmgr.ichunk->next; run->vmgr.ichunk = ASE_NULL;
ASE_AWK_FREE (run->awk, run->vmgr.ichunk); run->vmgr.rchunk = ASE_NULL;
run->vmgr.ichunk = next;
}
while (run->vmgr.rchunk != ASE_NULL)
{
ase_awk_val_chunk_t* next = run->vmgr.rchunk->next;
ASE_AWK_FREE (run->awk, run->vmgr.rchunk);
run->vmgr.rchunk = next;
}
} }
static int build_runarg ( static int build_runarg (

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c 115 2008-03-03 11:13:15Z baconevi $ * $Id: val.c 155 2008-03-22 06:47:27Z baconevi $
* *
* {License} * {License}
*/ */
@ -12,6 +12,32 @@
#define CHUNKSIZE 100 #define CHUNKSIZE 100
typedef struct ase_awk_val_ichunk_t ase_awk_val_ichunk_t;
typedef struct ase_awk_val_rchunk_t ase_awk_val_rchunk_t;
struct ase_awk_val_chunk_t
{
ase_awk_val_chunk_t* next;
};
struct ase_awk_val_ichunk_t
{
ase_awk_val_chunk_t* next;
/* make sure that it has the same fields as
ase_awk_val_chunk_t up to this point */
ase_awk_val_int_t slot[CHUNKSIZE];
};
struct ase_awk_val_rchunk_t
{
ase_awk_val_chunk_t* next;
/* make sure that it has the same fields as
ase_awk_val_chunk_t up to this point */
ase_awk_val_real_t slot[CHUNKSIZE];
};
static ase_char_t* str_to_str ( static ase_char_t* str_to_str (
ase_awk_run_t* run, const ase_char_t* str, ase_size_t str_len, ase_awk_run_t* run, const ase_char_t* str, ase_size_t str_len,
int opt, ase_str_t* buf, ase_size_t* len); int opt, ase_str_t* buf, ase_size_t* len);
@ -89,13 +115,19 @@ ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v)
if (run->vmgr.ifree == ASE_NULL) if (run->vmgr.ifree == ASE_NULL)
{ {
ase_awk_val_chunk_t* c; ase_awk_val_ichunk_t* c;
ase_awk_val_int_t* x; ase_awk_val_int_t* x;
ase_size_t i; ase_size_t i;
c = ASE_AWK_MALLOC (run->awk, /* use ase_awk_val_ichunk structure to avoid
* any alignment issues on platforms requiring
* aligned memory access - using the code commented out
* will cause a fault on such a platform */
/* c = ASE_AWK_MALLOC (run->awk,
ASE_SIZEOF(ase_awk_val_chunk_t)+ ASE_SIZEOF(ase_awk_val_chunk_t)+
ASE_SIZEOF(ase_awk_val_int_t)*CHUNKSIZE); ASE_SIZEOF(ase_awk_val_int_t)*CHUNKSIZE); */
c = ASE_AWK_MALLOC (run->awk, ASE_SIZEOF(ase_awk_val_ichunk_t));
if (c == ASE_NULL) if (c == ASE_NULL)
{ {
ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);
@ -103,15 +135,24 @@ ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v)
} }
c->next = run->vmgr.ichunk; c->next = run->vmgr.ichunk;
run->vmgr.ichunk = c; /*run->vmgr.ichunk = c;*/
run->vmgr.ichunk = (ase_awk_val_chunk_t*)c;
x = (ase_awk_val_int_t*)(c + 1); /*x = (ase_awk_val_int_t*)(c + 1);
for (i = 0; i < CHUNKSIZE-1; i++) for (i = 0; i < CHUNKSIZE-1; i++)
x[i].nde = (ase_awk_nde_int_t*)&x[i+1]; x[i].nde = (ase_awk_nde_int_t*)&x[i+1];
x[i].nde = ASE_NULL; x[i].nde = ASE_NULL;
run->vmgr.ifree = x; run->vmgr.ifree = x;
*/
for (i = 0; i < CHUNKSIZE-1; i++)
c->slot[i].nde = (ase_awk_nde_int_t*)&c->slot[i+1];
c->slot[i].nde = ASE_NULL;
run->vmgr.ifree = &c->slot[0];
} }
val = run->vmgr.ifree; val = run->vmgr.ifree;
run->vmgr.ifree = (ase_awk_val_int_t*)val->nde; run->vmgr.ifree = (ase_awk_val_int_t*)val->nde;
@ -149,13 +190,14 @@ ase_awk_val_t* ase_awk_makerealval (ase_awk_run_t* run, ase_real_t v)
if (run->vmgr.rfree == ASE_NULL) if (run->vmgr.rfree == ASE_NULL)
{ {
ase_awk_val_chunk_t* c; ase_awk_val_rchunk_t* c;
ase_awk_val_real_t* x; ase_awk_val_real_t* x;
ase_size_t i; ase_size_t i;
c = ASE_AWK_MALLOC (run->awk, /* c = ASE_AWK_MALLOC (run->awk,
ASE_SIZEOF(ase_awk_val_chunk_t)+ ASE_SIZEOF(ase_awk_val_chunk_t)+
ASE_SIZEOF(ase_awk_val_real_t)*CHUNKSIZE); ASE_SIZEOF(ase_awk_val_real_t)*CHUNKSIZE); */
c = ASE_AWK_MALLOC (run->awk, ASE_SIZEOF(ase_awk_val_rchunk_t));
if (c == ASE_NULL) if (c == ASE_NULL)
{ {
ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM); ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);
@ -163,15 +205,25 @@ ase_awk_val_t* ase_awk_makerealval (ase_awk_run_t* run, ase_real_t v)
} }
c->next = run->vmgr.rchunk; c->next = run->vmgr.rchunk;
run->vmgr.rchunk = c; /*run->vmgr.rchunk = c;*/
run->vmgr.ichunk = (ase_awk_val_chunk_t*)c;
/*
x = (ase_awk_val_real_t*)(c + 1); x = (ase_awk_val_real_t*)(c + 1);
for (i = 0; i < CHUNKSIZE-1; i++) for (i = 0; i < CHUNKSIZE-1; i++)
x[i].nde = (ase_awk_nde_real_t*)&x[i+1]; x[i].nde = (ase_awk_nde_real_t*)&x[i+1];
x[i].nde = ASE_NULL; x[i].nde = ASE_NULL;
run->vmgr.rfree = x; run->vmgr.rfree = x;
*/
for (i = 0; i < CHUNKSIZE-1; i++)
c->slot[i].nde = (ase_awk_nde_real_t*)&c->slot[i+1];
c->slot[i].nde = ASE_NULL;
run->vmgr.rfree = &c->slot[0];
} }
val = run->vmgr.rfree; val = run->vmgr.rfree;
run->vmgr.rfree = (ase_awk_val_real_t*)val->nde; run->vmgr.rfree = (ase_awk_val_real_t*)val->nde;
@ -574,6 +626,16 @@ void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val)
val->ref--; val->ref--;
} }
void ase_awk_freevalchunk (ase_awk_run_t* run, ase_awk_val_chunk_t* chunk)
{
while (chunk != ASE_NULL)
{
ase_awk_val_chunk_t* next = chunk->next;
ASE_AWK_FREE (run->awk, chunk);
chunk = next;
}
}
ase_bool_t ase_awk_valtobool (ase_awk_run_t* run, ase_awk_val_t* val) ase_bool_t ase_awk_valtobool (ase_awk_run_t* run, ase_awk_val_t* val)
{ {
if (val == ASE_NULL) return ase_false; if (val == ASE_NULL) return ase_false;
@ -1067,3 +1129,4 @@ void ase_awk_dprintval (ase_awk_run_t* run, ase_awk_val_t* val)
DPRINTF (DCUSTOM, ASE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n")); DPRINTF (DCUSTOM, ASE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.h 115 2008-03-03 11:13:15Z baconevi $ * $Id: val.h 155 2008-03-22 06:47:27Z baconevi $
* *
* {License} * {License}
*/ */
@ -151,11 +151,6 @@ struct ase_awk_val_ref_t
ase_awk_val_t** adr; ase_awk_val_t** adr;
}; };
struct ase_awk_val_chunk_t
{
ase_awk_val_chunk_t* next;
};
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -189,10 +184,13 @@ ase_awk_val_t* ase_awk_makerefval (
ase_bool_t ase_awk_isstaticval (ase_awk_val_t* val); ase_bool_t ase_awk_isstaticval (ase_awk_val_t* val);
void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache); void ase_awk_freeval (ase_awk_run_t* run, ase_awk_val_t* val, ase_bool_t cache);
void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val); void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val);
void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val); void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val);
void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val); void ase_awk_refdownval_nofree (ase_awk_run_t* run, ase_awk_val_t* val);
void ase_awk_freevalchunk (ase_awk_run_t* run, ase_awk_val_chunk_t* chunk);
ase_bool_t ase_awk_valtobool ( ase_bool_t ase_awk_valtobool (
ase_awk_run_t* run, ase_awk_val_t* val); ase_awk_run_t* run, ase_awk_val_t* val);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: types.h 152 2008-03-21 11:57:29Z baconevi $ * $Id: types.h 155 2008-03-22 06:47:27Z baconevi $
* *
* {License} * {License}
*/ */
@ -193,7 +193,11 @@ typedef int ase_mcint_t;
typedef int ase_wchar_t; typedef int ase_wchar_t;
typedef int ase_wcint_t; typedef int ase_wcint_t;
#elif defined(hpux) || defined(__hpux) || defined(__hpux__) #elif defined(hpux) || defined(__hpux) || defined(__hpux__)
#if defined(__HP_cc) || defined(__HP_aCC)
typedef unsigned int ase_wchar_t; typedef unsigned int ase_wchar_t;
#else
typedef int ase_wchar_t;
#endif
typedef int ase_wcint_t; typedef int ase_wcint_t;
#elif ASE_SIZEOF_LONG == 4 #elif ASE_SIZEOF_LONG == 4
typedef long ase_wchar_t; typedef long ase_wchar_t;