*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-22 14:46:43 +00:00
parent dee0475031
commit b8ecc04150
5 changed files with 96 additions and 27 deletions

29
ase/cmn/makefile.msw.bcc Normal file
View File

@ -0,0 +1,29 @@
OUT = asecmn
C_SRCS = str.c
C_OBJS = $(C_SRCS:.c=.obj)
CC = bcc32
LD = ilink32
AR = tlib
JAVAC = javac
CFLAGS = -O2 -WM -WU -RT- -w -q -I../.. -DNDEBUG
LDFLAGS = -Tpd -ap -Gn -c -q
STARTUP = c0d32w.obj
LIBS = import32.lib cw32mt.lib
all: lib
lib: $(C_OBJS)
$(AR) $(OUT).lib @&&!
+-$(**: = &^
+-)
!
clean:
-del $(OBJS) $(OUT).lib *.obj
.SUFFIXES: .c .obj
.c.obj:
$(CC) $(CFLAGS) -c $<

View File

@ -1,28 +1,28 @@
/*
* $Id: str.c,v 1.1 2007-02-22 14:32:08 bacon Exp $
* $Id: str.c,v 1.2 2007-02-22 14:46:43 bacon Exp $
*
* {License}
*/
#include <ase/cmn/str.h>
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa)
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr)
{
if (str == ASE_NULL)
{
str = (ase_str_t*)
ASE_AWK_MALLOC (awk, ASE_SIZEOF(ase_str_t));
ASE_MALLOC (mmgr, ASE_SIZEOF(ase_str_t));
if (str == ASE_NULL) return ASE_NULL;
str->__dynamic = ase_true;
}
else str->__dynamic = ase_false;
str->awk = awk;
str->buf = (ase_char_t*) ASE_AWK_MALLOC (
awk, ASE_SIZEOF(ase_char_t) * (capa + 1));
str->mmgr = mmgr;
str->buf = (ase_char_t*) ASE_MALLOC (
mmgr, ASE_SIZEOF(ase_char_t) * (capa + 1));
if (str->buf == ASE_NULL)
{
if (str->__dynamic) ASE_AWK_FREE (awk, str);
if (str->__dynamic) ASE_FREE (mmgr, str);
return ASE_NULL;
}
@ -35,8 +35,8 @@ ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa)
void ase_str_close (ase_str_t* str)
{
ASE_AWK_FREE (str->awk, str->buf);
if (str->__dynamic) ASE_AWK_FREE (str->awk, str);
ASE_FREE (str->mmgr, str->buf);
if (str->__dynamic) ASE_FREE (str->mmgr, str);
}
void ase_str_clear (ase_str_t* str)
@ -47,7 +47,7 @@ void ase_str_clear (ase_str_t* str)
void ase_str_forfeit (ase_str_t* str)
{
if (str->__dynamic) ASE_AWK_FREE (str->awk, str);
if (str->__dynamic) ASE_FREE (str->mmgr, str);
}
void ase_str_swap (ase_str_t* str, ase_str_t* str1)
@ -57,17 +57,17 @@ void ase_str_swap (ase_str_t* str, ase_str_t* str1)
tmp.buf = str->buf;
tmp.size = str->size;
tmp.capa = str->capa;
tmp.awk = str->awk;
tmp.mmgr = str->mmgr;
str->buf = str1->buf;
str->size = str1->size;
str->capa = str1->capa;
str->awk = str1->awk;
str->mmgr = str1->mmgr;
str1->buf = tmp.buf;
str1->size = tmp.size;
str1->capa = tmp.capa;
str1->awk = tmp.awk;
str1->mmgr = tmp.mmgr;
}
ase_size_t ase_str_cpy (ase_str_t* str, const ase_char_t* s)
@ -82,11 +82,11 @@ ase_size_t ase_str_ncpy (ase_str_t* str, const ase_char_t* s, ase_size_t len)
if (len > str->capa)
{
buf = (ase_char_t*) ASE_AWK_MALLOC (
str->awk, ASE_SIZEOF(ase_char_t) * (len + 1));
buf = (ase_char_t*) ASE_MALLOC (
str->mmgr, ASE_SIZEOF(ase_char_t) * (len + 1));
if (buf == ASE_NULL) return (ase_size_t)-1;
ASE_AWK_FREE (str->awk, str->buf);
ASE_FREE (str->mmgr, str->buf);
str->capa = len;
str->buf = buf;
}
@ -114,23 +114,23 @@ ase_size_t ase_str_ncat (ase_str_t* str, const ase_char_t* s, ase_size_t len)
/* double the capa if necessary for concatenation */
if (capa < str->capa * 2) capa = str->capa * 2;
if (str->awk->prmfns.realloc != ASE_NULL)
if (str->mmgr->realloc != ASE_NULL)
{
tmp = (ase_char_t*) ASE_AWK_REALLOC (
str->awk, str->buf,
tmp = (ase_char_t*) ASE_REALLOC (
str->mmgr, str->buf,
ASE_SIZEOF(ase_char_t) * (capa + 1));
if (tmp == ASE_NULL) return (ase_size_t)-1;
}
else
{
tmp = (ase_char_t*) ASE_AWK_MALLOC (
str->awk, ASE_SIZEOF(ase_char_t) * (capa + 1));
tmp = (ase_char_t*) ASE_MALLOC (
str->mmgr, ASE_SIZEOF(ase_char_t) * (capa + 1));
if (tmp == ASE_NULL) return (ase_size_t)-1;
if (str->buf != ASE_NULL)
{
ASE_AWK_MEMCPY (str->awk, tmp, str->buf,
ASE_MEMCPY (str->mmgr, tmp, str->buf,
ASE_SIZEOF(ase_char_t) * (str->capa + 1));
ASE_AWK_FREE (str->awk, str->buf);
ASE_FREE (str->mmgr, str->buf);
}
}

View File

@ -1,5 +1,5 @@
/*
* $Id: str.h,v 1.1 2007-02-22 14:32:08 bacon Exp $
* $Id: str.h,v 1.2 2007-02-22 14:46:43 bacon Exp $
*
* {License}
*/
@ -23,6 +23,7 @@ struct ase_str_t
ase_char_t* buf;
ase_size_t size;
ase_size_t capa;
ase_mmgr_t* mmgr;
ase_bool_t __dynamic;
};
@ -30,7 +31,7 @@ struct ase_str_t
extern "C" {
#endif
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_t* awk);
ase_str_t* ase_str_open (ase_str_t* str, ase_size_t capa, ase_mmgr_t* mmgr);
void ase_str_close (ase_str_t* str);
void ase_str_clear (ase_str_t* str);

View File

@ -1,5 +1,5 @@
/*
* $Id: macros.h,v 1.49 2007-02-18 16:45:45 bacon Exp $
* $Id: macros.h,v 1.50 2007-02-22 14:46:42 bacon Exp $
*
* {License}
*/
@ -96,4 +96,25 @@
#define ASE_END_PACKED_STRUCT() };
#endif
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define ASE_MALLOC(mmgr,size) malloc (size)
#define ASE_REALLOC(mmgr,ptr,size) realloc (ptr, size)
#define ASE_FREE(mmgr,ptr) free (ptr)
#else
#define ASE_MALLOC(mmgr,size) \
(mmgr)->malloc (size, (mmgr)->custom_data)
#define ASE_REALLOC(mmgr,ptr,size) \
(mmgr)->realloc (ptr, size, (mmgr)->custom_data)
#define ASE_FREE(mmgr,ptr) \
(mmgr)->free (ptr, (mmgr)->custom_data)
#endif
#define ASE_MEMCPY(mmgr,dst,src,len) (mmgr)->memcpy (dst, src, len)
#define ASE_MEMSET(mmgr,dst,val,len) (mmgr)->memset (dst, val, len)
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: types.h,v 1.69 2007-02-11 09:18:32 bacon Exp $
* $Id: types.h,v 1.70 2007-02-22 14:46:42 bacon Exp $
*
* {License}
*/
@ -230,8 +230,26 @@ typedef int ase_mcint_t;
#endif
#endif
typedef void* (*ase_malloc_t) (ase_size_t n, void* custom_data);
typedef void* (*ase_realloc_t) (void* ptr, ase_size_t n, void* custom_data);
typedef void (*ase_free_t) (void* ptr, void* custom_data);
typedef void* (*ase_memcpy_t) (void* dst, const void* src, ase_size_t n);
typedef void* (*ase_memset_t) (void* dst, int val, ase_size_t n);
typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_cstr_t ase_cstr_t;
struct ase_mmgr_t
{
void* custom_data;
ase_malloc_t malloc;
ase_realloc_t realloc;
ase_free_t free;
ase_memcpy_t memcpy;
ase_memset_t memset;
};
struct ase_cstr_t
{
ase_char_t* ptr;