From 4ba998a693989f0fd8e359774828e4ffefdbf307 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 23 Feb 2007 07:13:58 +0000 Subject: [PATCH] *** empty log message *** --- ase/cmn/makefile.in | 2 +- ase/cmn/mem.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ ase/cmn/mem.h | 25 ++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 ase/cmn/mem.c create mode 100644 ase/cmn/mem.h diff --git a/ase/cmn/makefile.in b/ase/cmn/makefile.in index 2a511ab0..3d49fb53 100644 --- a/ase/cmn/makefile.in +++ b/ase/cmn/makefile.in @@ -1,6 +1,6 @@ OUT = asecmn -C_SRCS = str.c +C_SRCS = mem.c str.c C_OBJS = $(C_SRCS:.c=.o) CC = @CC@ diff --git a/ase/cmn/mem.c b/ase/cmn/mem.c new file mode 100644 index 00000000..4fa97e59 --- /dev/null +++ b/ase/cmn/mem.c @@ -0,0 +1,52 @@ +/* + * $Id: mem.c,v 1.1 2007-02-23 07:13:58 bacon Exp $ + * + * {License} + */ + +#include + +void* ase_memcpy (void* dst, const void* src, ase_size_t n) +{ + void* p = dst; + void* e = (ase_byte_t*)dst + n; + + while (dst < e) + { + *(ase_byte_t*)dst = *(ase_byte_t*)src; + dst = (ase_byte_t*)dst + 1; + src = (ase_byte_t*)src + 1; + } + + return p; +} + +void* ase_memset (void* dst, int val, ase_size_t n) +{ + void* p = dst; + void* e = (ase_byte_t*)p + n; + + while (p < e) + { + *(ase_byte_t*)p = (ase_byte_t)val; + p = (ase_byte_t*)p + 1; + } + + return dst; +} + +int ase_memcmp (const void* s1, const void* s2, ase_size_t n) +{ + const void* e; + + if (n == 0) return 0; + + e = (const ase_byte_t*)s1 + n - 1; + while (s1 < e && *(ase_byte_t*)s1 == *(ase_byte_t*)s2) + { + s1 = (ase_byte_t*)s1 + 1; + s2 = (ase_byte_t*)s2 + 1; + } + + return *((ase_byte_t*)s1) - *((ase_byte_t*)s2); +} diff --git a/ase/cmn/mem.h b/ase/cmn/mem.h new file mode 100644 index 00000000..6848f5da --- /dev/null +++ b/ase/cmn/mem.h @@ -0,0 +1,25 @@ +/* + * $Id: mem.h,v 1.1 2007-02-23 07:13:58 bacon Exp $ + * + * {License} + */ + +#ifndef _ASE_CMN_MEM_H_ +#define _ASE_CMN_MEM_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void* ase_memcpy (void* dst, const void* src, ase_size_t n); +void* ase_memset (void* dst, int val, ase_size_t n); +int ase_memcmp (const void* s1, const void* s2, ase_size_t n); + +#ifdef __cplusplus +} +#endif + +#endif