summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2005-04-07 20:15:21 +0000
committerfoobar <sniper@php.net>2005-04-07 20:15:21 +0000
commit355eefe5f9f42ba4fbf0ae6b9f0352765370dc16 (patch)
tree0e7c681bcbd8b23e466b3c131a58062fb42c42eb
parent9356d7fc640c891f7fd2f58d0896150d8671eacb (diff)
downloadphp-git-355eefe5f9f42ba4fbf0ae6b9f0352765370dc16.tar.gz
- Nuke the code duplication
-rw-r--r--Zend/zend_alloc.c10
-rw-r--r--Zend/zend_alloc.h15
2 files changed, 5 insertions, 20 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 79041ed263..ef6f6cceb3 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -409,16 +409,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 ac99dcde7d..21d7b51052 100644
--- a/Zend/zend_alloc.h
+++ b/Zend/zend_alloc.h
@@ -125,17 +125,12 @@ 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)):STR_EMPTY_ALLOC())
-#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):STR_EMPTY_ALLOC())
-
#else
#define _GNU_SOURCE
#include <string.h>
#undef _GNU_SOURCE
-char *_strndup(char *s, uint l);
-
/* Standard wrapper macros */
#define emalloc(size) malloc(size)
#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset))
@@ -144,7 +139,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)
@@ -154,7 +149,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)
@@ -172,10 +167,10 @@ char *_strndup(char *s, uint l);
#define perealloc_recoverable_rel(ptr, size, persistent) realloc((ptr), (size))
#define pestrdup_rel(s, persistent) strdup(s)
-#define safe_estrdup(ptr) ((ptr)?(strdup(ptr)):(STR_EMPTY_ALLOC()))
-#define safe_estrndup(ptr, len) ((ptr)?(_strndup((ptr), (len))):(STR_EMPTY_ALLOC()))
+#endif /* !USE_ZEND_ALLOC */
-#endif
+#define safe_estrdup(ptr) ((ptr)?(estrdup(ptr)):STR_EMPTY_ALLOC())
+#define safe_estrndup(ptr, len) ((ptr)?(estrndup((ptr), (len))):STR_EMPTY_ALLOC())
ZEND_API int zend_set_memory_limit(unsigned int memory_limit);