*** empty log message ***
This commit is contained in:
29
ase/cmn/makefile.msw.bcc
Normal file
29
ase/cmn/makefile.msw.bcc
Normal 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 $<
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user