This commit is contained in:
parent
6effdf92ad
commit
9a6365bbe8
@ -14,38 +14,50 @@
|
||||
/* sets a pointer to the default memory manager */
|
||||
#define ASE_CCLS_SETDFL(m) ((ase_ccls)=(m))
|
||||
|
||||
#define ASE_CCLS_ISUPPER(ccls,c) (ccls)->is_upper((ccls)->data,c)
|
||||
#define ASE_CCLS_ISLOWER(ccls,c) (ccls)->is_lower((ccls)->data,c)
|
||||
#define ASE_CCLS_ISALPHA(ccls,c) (ccls)->is_alpha((ccls)->data,c)
|
||||
#define ASE_CCLS_ISDIGIT(ccls,c) (ccls)->is_digit((ccls)->data,c)
|
||||
#define ASE_CCLS_ISXDIGIT(ccls,c) (ccls)->is_xdigit((ccls)->data,c)
|
||||
#define ASE_CCLS_ISALNUM(ccls,c) (ccls)->is_alnum((ccls)->data,c)
|
||||
#define ASE_CCLS_ISSPACE(ccls,c) (ccls)->is_space((ccls)->data,c)
|
||||
#define ASE_CCLS_ISPRINT(ccls,c) (ccls)->is_print((ccls)->data,c)
|
||||
#define ASE_CCLS_ISGRAPH(ccls,c) (ccls)->is_graph((ccls)->data,c)
|
||||
#define ASE_CCLS_ISCNTRL(ccls,c) (ccls)->is_cntrl((ccls)->data,c)
|
||||
#define ASE_CCLS_ISPUNCT(ccls,c) (ccls)->is_punct((ccls)->data,c)
|
||||
#define ASE_CCLS_TOUPPER(ccls,c) (ccls)->to_upper((ccls)->data,c)
|
||||
#define ASE_CCLS_TOLOWER(ccls,c) (ccls)->to_lower((ccls)->data,c)
|
||||
enum ase_ccls_type_t
|
||||
{
|
||||
ASE_CCLS_UPPER,
|
||||
ASE_CCLS_LOWER,
|
||||
ASE_CCLS_ALPHA,
|
||||
ASE_CCLS_DIGIT,
|
||||
ASE_CCLS_XDIGIT,
|
||||
ASE_CCLS_ALNUM,
|
||||
ASE_CCLS_SPACE,
|
||||
ASE_CCLS_PRINT,
|
||||
ASE_CCLS_GRAPH,
|
||||
ASE_CCLS_CNTRL,
|
||||
ASE_CCLS_PUNCT
|
||||
};
|
||||
|
||||
struct ase_ccls_t
|
||||
{
|
||||
ase_bool_t(*is) (void* data, ase_cint_t c, ase_ccls_type_t type);
|
||||
ase_cint_t(*to) (void* data, ase_cint_t c, ase_ccls_type_t type);
|
||||
void* data;
|
||||
};
|
||||
|
||||
#define ASE_CCLS_IS(ccls,c,is) ((ccls)->is((ccls)->data,c,is))
|
||||
#define ASE_CCLS_TO(ccls,c,to) ((ccls)->to((ccls)->data,c,to))
|
||||
|
||||
#define ASE_CCLS_ISUPPER(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_UPPER)
|
||||
#define ASE_CCLS_ISLOWER(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_LOWER)
|
||||
#define ASE_CCLS_ISALPHA(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_ALPHA)
|
||||
#define ASE_CCLS_ISDIGIT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_DIGIT)
|
||||
#define ASE_CCLS_ISXDIGIT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_XDIGIT)
|
||||
#define ASE_CCLS_ISALNUM(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_ALNUM)
|
||||
#define ASE_CCLS_ISSPACE(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_SPACE)
|
||||
#define ASE_CCLS_ISPRINT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_PRINT)
|
||||
#define ASE_CCLS_ISGRAPH(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_GRAPH)
|
||||
#define ASE_CCLS_ISCNTRL(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_CNTRL)
|
||||
#define ASE_CCLS_ISPUNCT(ccls,c) ASE_CCLS_IS(ccls,c,ASE_CCLS_PUNCT)
|
||||
#define ASE_CCLS_TOUPPER(ccls,c) ASE_CCLS_TO(ccls,c,ASE_CCLS_UPPER)
|
||||
#define ASE_CCLS_TOLOWER(ccls,c) ASE_CCLS_TO(ccls,c,ASE_CCLS_LOWER)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
ase_bool_t ase_isupper (ase_cint_t c);
|
||||
ase_bool_t ase_islower (ase_cint_t c);
|
||||
ase_bool_t ase_isalpha (ase_cint_t c);
|
||||
ase_bool_t ase_isdigit (ase_cint_t c);
|
||||
ase_bool_t ase_isxdigit (ase_cint_t c);
|
||||
ase_bool_t ase_isalnum (ase_cint_t c);
|
||||
ase_bool_t ase_isspace (ase_cint_t c);
|
||||
ase_bool_t ase_isprint (ase_cint_t c);
|
||||
ase_bool_t ase_isgraph (ase_cint_t c);
|
||||
ase_bool_t ase_iscntrl (ase_cint_t c);
|
||||
ase_bool_t ase_ispunct (ase_cint_t c);
|
||||
|
||||
ase_cint_t ase_toupper (ase_cint_t c);
|
||||
ase_cint_t ase_tolower (ase_cint_t c);
|
||||
extern ase_ccls_t* ase_ccls;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: mem.h 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: mem.h 335 2008-08-20 08:22:07Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -18,7 +18,7 @@
|
||||
|
||||
/* allocate a memory block */
|
||||
#define ASE_MMGR_ALLOC(mmgr,size) \
|
||||
(mmgr)->malloc((mmgr)->data,size)
|
||||
(mmgr)->alloc((mmgr)->data,size)
|
||||
|
||||
/* reallocate a memory block */
|
||||
#define ASE_MMGR_REALLOC(mmgr,ptr,size) \
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: types.h 332 2008-08-18 11:21:48Z baconevi $
|
||||
* $Id: types.h 335 2008-08-20 08:22:07Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -329,12 +329,12 @@ typedef struct ase_cstr_t ase_cstr_t;
|
||||
typedef struct ase_mmgr_t ase_mmgr_t;
|
||||
typedef struct ase_ccls_t ase_ccls_t;
|
||||
|
||||
typedef void* (*ase_malloc_t) (void* custom, ase_size_t n);
|
||||
typedef void* (*ase_realloc_t) (void* custom, void* ptr, ase_size_t n);
|
||||
typedef void (*ase_free_t) (void* custom, void* ptr);
|
||||
typedef void* (*ase_alloc_t) (void* data, ase_size_t n);
|
||||
typedef void* (*ase_realloc_t) (void* data, void* ptr, ase_size_t n);
|
||||
typedef void (*ase_free_t) (void* data, void* ptr);
|
||||
|
||||
typedef ase_bool_t (*ase_isccls_t) (void* custom, ase_cint_t c);
|
||||
typedef ase_cint_t (*ase_toccls_t) (void* custom, ase_cint_t c);
|
||||
typedef ase_bool_t (*ase_isccls_t) (void* data, ase_cint_t c);
|
||||
typedef ase_cint_t (*ase_toccls_t) (void* data, ase_cint_t c);
|
||||
|
||||
struct ase_cstr_t
|
||||
{
|
||||
@ -344,7 +344,7 @@ struct ase_cstr_t
|
||||
|
||||
struct ase_mmgr_t
|
||||
{
|
||||
ase_malloc_t malloc;
|
||||
ase_alloc_t alloc;
|
||||
ase_realloc_t realloc;
|
||||
ase_free_t free;
|
||||
void* data;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: mem.c 329 2008-08-16 14:08:53Z baconevi $
|
||||
* $Id: mem.c 335 2008-08-20 08:22:07Z baconevi $
|
||||
*
|
||||
* {License}
|
||||
*/
|
||||
@ -401,24 +401,24 @@ 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)
|
||||
static void* mmgr_alloc (void* data, ase_size_t n)
|
||||
{
|
||||
return malloc (n);
|
||||
}
|
||||
|
||||
static void* mmgr_realloc (void* custom, void* ptr, ase_size_t n)
|
||||
static void* mmgr_realloc (void* data, void* ptr, ase_size_t n)
|
||||
{
|
||||
return realloc (ptr, n);
|
||||
}
|
||||
|
||||
static void mmgr_free (void* custom, void* ptr)
|
||||
static void mmgr_free (void* data, void* ptr)
|
||||
{
|
||||
free (ptr);
|
||||
}
|
||||
|
||||
static ase_mmgr_t mmgr =
|
||||
{
|
||||
mmgr_malloc,
|
||||
mmgr_alloc,
|
||||
mmgr_realloc,
|
||||
mmgr_free,
|
||||
ASE_NULL
|
||||
|
Loading…
x
Reference in New Issue
Block a user