cvs: Zend(PHP_4_3) / zend_alloc.c zend_alloc.h
| From: | Derick Rethans | Date: | Thu, 07 Apr 2005 14:43:38 +0000 |
| Subject: | cvs: Zend(PHP_4_3) / zend_alloc.c zend_alloc.h | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-3539@lists.php.net to get a copy of this message | ||
derick Thu Apr 7 10:43:38 2005 EDT
Modified files: (Branch: PHP_4_3)
/Zend zend_alloc.c zend_alloc.h
Log:
- Fixed bug with estrndup when the Zend Allocator was not in use.
#- Zeev was so nice to commit my patch for PHP 5.x - but I need it for 4.[34] :)
http://cvs.php.net/diff.php/Zend/zend_alloc.c?r1=1.105.4.7&r2=1.105.4.8&ty=u
Index: Zend/zend_alloc.c
diff -u Zend/zend_alloc.c:1.105.4.7 Zend/zend_alloc.c:1.105.4.8
--- Zend/zend_alloc.c:1.105.4.7 Fri Aug 27 12:51:25 2004
+++ Zend/zend_alloc.c Thu Apr 7 10:43:37 2005
@@ -372,6 +372,15 @@
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)
{
http://cvs.php.net/diff.php/Zend/zend_alloc.h?r1=1.39.4.7&r2=1.39.4.8&ty=u
Index: Zend/zend_alloc.h
diff -u Zend/zend_alloc.h:1.39.4.7 Zend/zend_alloc.h:1.39.4.8
--- Zend/zend_alloc.h:1.39.4.7 Wed Aug 11 02:10:46 2004
+++ Zend/zend_alloc.h Thu Apr 7 10:43:37 2005
@@ -80,7 +80,7 @@
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
ZEND_ATTRIBUTE_MALLOC;
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC
ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
-#define USE_ZEND_ALLOC 1
+#define USE_ZEND_ALLOC 0
#if USE_ZEND_ALLOC
@@ -121,6 +121,8 @@
#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))
@@ -129,7 +131,7 @@
#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) _strndup((s), (length))
/* Relay wrapper macros */
#define emalloc_rel(size) malloc(size)
@@ -139,7 +141,7 @@
#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) _strndup((s), (length))
/* Selective persistent/non persistent allocation macros */
#define pemalloc(size, persistent) malloc(size)
@@ -150,7 +152,7 @@
#define pestrdup(s, persistent) strdup(s)
#define safe_estrdup(ptr) ((ptr)?(strdup(ptr)):(empty_string))
-#define safe_estrndup(ptr, len) ((ptr)?(strndup((ptr), (len))):(empty_string))
+#define safe_estrndup(ptr, len) ((ptr)?(_strndup((ptr), (len))):(empty_string))
#endif