cvs: ZendEngine2(PHP_5_0) / zend_alloc.c zend_alloc.h

From: Date: Thu, 07 Apr 2005 14:00:00 +0000
Subject: cvs: ZendEngine2(PHP_5_0) / zend_alloc.c zend_alloc.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3538@lists.php.net to get a copy of this message
zeev Thu Apr 7 10:00:00 2005 EDT Modified files: (Branch: PHP_5_0) /ZendEngine2 zend_alloc.c zend_alloc.h Log: MFH (Fix strdup() bug when USE_ZEND_ALLOC was disabled) http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.c?r1=1.137.2.1&r2=1.137.2.2&ty=u Index: ZendEngine2/zend_alloc.c diff -u ZendEngine2/zend_alloc.c:1.137.2.1 ZendEngine2/zend_alloc.c:1.137.2.2 --- ZendEngine2/zend_alloc.c:1.137.2.1 Fri Aug 27 12:49:54 2004 +++ ZendEngine2/zend_alloc.c Thu Apr 7 10:00:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_alloc.c,v 1.137.2.1 2004/08/27 16:49:54 andi Exp $ */ +/* $Id: zend_alloc.c,v 1.137.2.2 2005/04/07 14:00:00 zeev Exp $ */ #include "zend.h" #include "zend_alloc.h" @@ -388,6 +388,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/ZendEngine2/zend_alloc.h?r1=1.52.2.1&r2=1.52.2.2&ty=u Index: ZendEngine2/zend_alloc.h diff -u ZendEngine2/zend_alloc.h:1.52.2.1 ZendEngine2/zend_alloc.h:1.52.2.2 --- ZendEngine2/zend_alloc.h:1.52.2.1 Wed Aug 11 02:13:12 2004 +++ ZendEngine2/zend_alloc.h Thu Apr 7 10:00:00 2005 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_alloc.h,v 1.52.2.1 2004/08/11 06:13:12 derick Exp $ */ +/* $Id: zend_alloc.h,v 1.52.2.2 2005/04/07 14:00:00 zeev Exp $ */ #ifndef ZEND_ALLOC_H #define ZEND_ALLOC_H @@ -133,6 +133,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)) @@ -141,7 +143,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) @@ -151,7 +153,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) @@ -169,7 +171,7 @@ #define pestrdup_rel(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

« previous php.zend-engine.cvs (#3538) next »