From: foobar Date: Thu, 7 Apr 2005 21:05:19 +0000 (+0000) Subject: MFH: Nuke duplication X-Git-Tag: php-5.0.5RC1~467 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09a5954e6764cba79f2ad098b78e0b9664560c34;p=php MFH: Nuke duplication --- diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 5e3c70d25c..c5d37ed1cf 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -388,16 +388,6 @@ ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) return p; } -#if !USE_ZEND_ALLOC -char *_strndup(char *s, uint l) -{ - char *tmp = malloc(l+1); - tmp[l] = '\0'; - memcpy(tmp, s, l); - return tmp; -} -#endif - ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { char *p; diff --git a/Zend/zend_alloc.h b/Zend/zend_alloc.h index 62adc8e662..07a100d483 100644 --- a/Zend/zend_alloc.h +++ b/Zend/zend_alloc.h @@ -124,16 +124,11 @@ ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC ZE #define perealloc_recoverable_rel(ptr, size, persistent) ((persistent)?realloc((ptr), (size)):erealloc_recoverable_rel((ptr), (size))) #define pestrdup_rel(s, persistent) ((persistent)?strdup(s):estrdup_rel(s)) -#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string)) -#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):(empty_string)) - #else #define _GNU_SOURCE #include #undef _GNU_SOURCE - -char *_strndup(char *s, uint l); /* Standard wrapper macros */ #define emalloc(size) malloc(size) @@ -143,7 +138,7 @@ char *_strndup(char *s, uint l); #define erealloc(ptr, size) realloc((ptr), (size)) #define erealloc_recoverable(ptr, size) realloc((ptr), (size)) #define estrdup(s) strdup(s) -#define estrndup(s, length) _strndup((s), (length)) +#define estrndup(s, length) zend_strndup((s), (length)) /* Relay wrapper macros */ #define emalloc_rel(size) malloc(size) @@ -153,7 +148,7 @@ char *_strndup(char *s, uint l); #define erealloc_rel(ptr, size) realloc((ptr), (size)) #define erealloc_recoverable_rel(ptr, size) realloc((ptr), (size)) #define estrdup_rel(s) strdup(s) -#define estrndup_rel(s, length) _strndup((s), (length)) +#define estrndup_rel(s, length) zend_strndup((s), (length)) /* Selective persistent/non persistent allocation macros */ #define pemalloc(size, persistent) malloc(size) @@ -169,11 +164,10 @@ char *_strndup(char *s, uint l); #define perealloc_rel(ptr, size, persistent) realloc((ptr), (size)) #define perealloc_recoverable_rel(ptr, size, persistent) realloc((ptr), (size)) #define pestrdup_rel(s, persistent) strdup(s) +#endif /* !USE_ZEND_ALLOC */ -#define safe_estrdup(ptr) ((ptr)?(strdup(ptr)):(empty_string)) -#define safe_estrndup(ptr, len) ((ptr)?(_strndup((ptr), (len))):(empty_string)) - -#endif +#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):(empty_string)) +#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):(empty_string)) ZEND_API int zend_set_memory_limit(unsigned int memory_limit);