]> granicus.if.org Git - php/commitdiff
MFH: Nuke duplication
authorfoobar <sniper@php.net>
Thu, 7 Apr 2005 21:05:19 +0000 (21:05 +0000)
committerfoobar <sniper@php.net>
Thu, 7 Apr 2005 21:05:19 +0000 (21:05 +0000)
Zend/zend_alloc.c
Zend/zend_alloc.h

index 5e3c70d25cd2c21fa3c6d66122dc47593844818d..c5d37ed1cf30cbed902f90634ad7d0ce778cdae8 100644 (file)
@@ -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;
index 62adc8e6622439c48515baca16415b47f52502fa..07a100d4831a95ea308fdf769004e48e3910fbc3 100644 (file)
@@ -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 <string.h>
 #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);