From: tomo Date: Mon, 7 Jul 2003 10:17:38 +0000 (+0000) Subject: (strnlen): New inline function when HAVE_STRNLEN is not defined X-Git-Tag: r0_1_1-pre1~28 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=0b0743a906281220a95392421267747a21ab02d0;hp=64b3b1afb95ae6d19e1f896288936f543aa740cb;p=chise%2Flibchise.git (strnlen): New inline function when HAVE_STRNLEN is not defined [based on Izumi MIYAZAKI 's patch]. --- diff --git a/chise.h b/chise.h index 783df88..e384802 100644 --- a/chise.h +++ b/chise.h @@ -3,6 +3,25 @@ #include #include +#ifndef HAVE_STRNLEN + +/* original in mysql, strings/strnlen.c. +uint strnlen(register const char *s, register uint maxlen) +{ + const char *end= (const char *)memchr(s, '\0', maxlen); + return end ? (uint) (end - s) : maxlen; +} +*/ + +static inline int +strnlen (register const char *s, register int maxlen) +{ + const char *end= (const char *)memchr(s, '\0', maxlen); + return end ? (int) (end - s) : maxlen; +} + +#endif + typedef enum CHISE_DS_Type {