diff --git a/ase/cmd/awk/awk.c b/ase/cmd/awk/awk.c index 1c89813e..3ad100f1 100644 --- a/ase/cmd/awk/awk.c +++ b/ase/cmd/awk/awk.c @@ -1,9 +1,10 @@ /* - * $Id: awk.c 325 2008-08-13 14:22:29Z baconevi $ + * $Id: awk.c 329 2008-08-16 14:08:53Z baconevi $ */ #include #include +#include #include #include @@ -1288,7 +1289,7 @@ static int awk_main (int argc, ase_char_t* argv[]) ase_sll_t* sf; - sf = ase_sll_open (ASE_GETMMGR()); + sf = ase_sll_open (ASE_MMGR_GET()); if (sf == ASE_NULL) { out_of_memory (); diff --git a/ase/include/ase/utl/helper.h b/ase/include/ase/utl/helper.h index 4d2d23f2..6326adf0 100644 --- a/ase/include/ase/utl/helper.h +++ b/ase/include/ase/utl/helper.h @@ -1,5 +1,5 @@ /* - * $Id: helper.h 231 2008-06-28 08:37:09Z baconevi $ + * $Id: helper.h 329 2008-08-16 14:08:53Z baconevi $ */ #ifndef _ASE_UTL_HELPER_H_ @@ -8,9 +8,6 @@ #include #include -#define ASE_GETMMGR() (ase_mmgr) -#define ASE_SETMMGR(m) ((ase_mmgr) = (m)) - #define ASE_GETCCLS() (ase_ccls) #define ASE_SETCCLS(c) ((ase_ccls) = (c)) @@ -18,7 +15,6 @@ extern "C" { #endif -extern ase_mmgr_t* ase_mmgr; extern ase_ccls_t* ase_ccls; #ifdef __cplusplus diff --git a/ase/lib/awk/jni.c b/ase/lib/awk/jni.c index 85157365..1c37d26c 100644 --- a/ase/lib/awk/jni.c +++ b/ase/lib/awk/jni.c @@ -1,5 +1,5 @@ /* - * $Id: jni.c 271 2008-07-20 12:42:39Z baconevi $ + * $Id: jni.c 329 2008-08-16 14:08:53Z baconevi $ * * {License} */ @@ -327,7 +327,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj) #endif #endif - awk = ase_awk_open (ASE_GETMMGR(), ASE_SIZEOF(awk_data_t)); + awk = ase_awk_open (ASE_MMGR_GET(), ASE_SIZEOF(awk_data_t)); if (awk == ASE_NULL) { THROW_NOMEM_EXCEPTION (env); diff --git a/ase/lib/awk/std.c b/ase/lib/awk/std.c index 5388a2ff..d9eafe5f 100644 --- a/ase/lib/awk/std.c +++ b/ase/lib/awk/std.c @@ -45,7 +45,7 @@ ase_awk_t* ase_awk_openstd (void) ase_awk_t* awk; ext_t* ext; - awk = ase_awk_open (ASE_GETMMGR(), ASE_SIZEOF(ext_t), ASE_NULL); + awk = ase_awk_open (ASE_MMGR_GET(), ASE_SIZEOF(ext_t), ASE_NULL); ase_awk_setccls (awk, ASE_GETCCLS()); ext = (ext_t*) ase_awk_getextension (awk); diff --git a/ase/lib/cmn/mem.c b/ase/lib/cmn/mem.c index 06b1471d..eb0adf25 100644 --- a/ase/lib/cmn/mem.c +++ b/ase/lib/cmn/mem.c @@ -1,10 +1,11 @@ /* - * $Id: mem.c 177 2008-04-26 04:58:10Z baconevi $ + * $Id: mem.c 329 2008-08-16 14:08:53Z baconevi $ * * {License} */ #include +#include #if defined(__SPU__) #include @@ -399,3 +400,28 @@ void* ase_memrmem (const void* hs, ase_size_t hl, const void* nd, ase_size_t nl) return ASE_NULL; } + +static void* mmgr_malloc (void* custom, ase_size_t n) +{ + return malloc (n); +} + +static void* mmgr_realloc (void* custom, void* ptr, ase_size_t n) +{ + return realloc (ptr, n); +} + +static void mmgr_free (void* custom, void* ptr) +{ + free (ptr); +} + +static ase_mmgr_t mmgr = +{ + mmgr_malloc, + mmgr_realloc, + mmgr_free, + ASE_NULL +}; + +ase_mmgr_t* ase_mmgr = &mmgr; diff --git a/ase/lib/cmn/mem.h b/ase/lib/cmn/mem.h index 810ca0aa..232a1d4b 100644 --- a/ase/lib/cmn/mem.h +++ b/ase/lib/cmn/mem.h @@ -7,19 +7,28 @@ #ifndef _ASE_LIB_CMN_MEM_H_ #define _ASE_LIB_CMN_MEM_H_ +#include + #ifdef USE_STDC #include #define ASE_MEMCPY(dst,src,len) memcpy(dst,src,len) #define ASE_MEMCMP(p1,p2,len) memcmp(p1,p2,len) #define ASE_MEMSET(dst,val,len) memset(dst,val,len) +#define ASE_MEMBYTE(s,val,len) memchr(s,val,len) +#define ASE_MEMRBYTE(s,val,len) memrchr(s,val,len) +#define ASE_MEMMEM(hs,hl,nd,nl) memmem(hs,hl,nd,nl) +#define ASE_MEMRMEM(hs,hl,nd,nl) memrmem(hs,hl,nd,nl) #else -#include #define ASE_MEMCPY(dst,src,len) ase_memcpy(dst,src,len) #define ASE_MEMCMP(p1,p2,len) ase_memcmp(p1,p2,len) #define ASE_MEMSET(dst,val,len) ase_memset(dst,val,len) +#define ASE_MEMBYTE(s,val,len) ase_membyte(s,val,len) +#define ASE_MEMRBYTE(s,val,len) ase_memrbyte(s,val,len) +#define ASE_MEMMEM(hs,hl,nd,nl) ase_memmem(hs,hl,nd,nl) +#define ASE_MEMRMEM(hs,hl,nd,nl) ase_memrmem(hs,hl,nd,nl) #endif diff --git a/ase/lib/cmn/sll.c b/ase/lib/cmn/sll.c index 48db2a84..8fb6e136 100644 --- a/ase/lib/cmn/sll.c +++ b/ase/lib/cmn/sll.c @@ -13,15 +13,21 @@ void* ase_sll_copyinline (ase_sll_t* sll, void* dptr, ase_size_t dlen) return ASE_NULL; } -ase_sll_t* ase_sll_open (ase_mmgr_t* mmgr) +ase_sll_t* ase_sll_open () { return ase_sll_openx (mmgr, 0, ASE_NULL); } -ase_sll_t* ase_sll_openx (ase_mmgr_t* mmgr, ase_size_t extension, ase_fuser_t fuser) +ase_sll_openm (ase_mmgr_t* mmgr); +ase_sll_openx (ase_size_t extension, ase_fuser_t fuser); + +ase_sll_t* ase_sll_openf ( + ase_mmgr_t* mmgr, ase_size_t extension, ase_fuser_t fuser) { ase_sll_t* sll; + if (mmgr == ASE_NULL) mmgr = ASE_MMGR_GET (); + sll = ASE_MALLOC (mmgr, ASE_SIZEOF(ase_sll_t) + extension); if (sll == ASE_NULL) return ASE_NULL; diff --git a/ase/lib/utl/helper.c b/ase/lib/utl/helper.c index 5dd8cdd4..86f08cd2 100644 --- a/ase/lib/utl/helper.c +++ b/ase/lib/utl/helper.c @@ -1,26 +1,10 @@ /* - * $Id: helper.c 231 2008-06-28 08:37:09Z baconevi $ + * $Id: helper.c 329 2008-08-16 14:08:53Z baconevi $ */ #include #include -#include - -static void* mmgr_malloc (void* custom, ase_size_t n) -{ - return malloc (n); -} - -static void* mmgr_realloc (void* custom, void* ptr, ase_size_t n) -{ - return realloc (ptr, n); -} - -static void mmgr_free (void* custom, void* ptr) -{ - free (ptr); -} static ase_bool_t ccls_isupper (void* custom, ase_cint_t c) { @@ -87,14 +71,6 @@ static ase_cint_t ccls_tolower (void* custom, ase_cint_t c) return ase_tolower (c); } -static ase_mmgr_t mmgr = -{ - mmgr_malloc, - mmgr_realloc, - mmgr_free, - ASE_NULL -}; - static ase_ccls_t ccls = { ccls_isupper, @@ -113,5 +89,4 @@ static ase_ccls_t ccls = ASE_NULL }; -ase_mmgr_t* ase_mmgr = &mmgr; ase_ccls_t* ase_ccls = &ccls;