cvs: ZendEngine2 / zend_alloc.h

From: Date: Sat, 07 Aug 2004 00:45:34 +0000
Subject: cvs: ZendEngine2 / zend_alloc.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-2851@lists.php.net to get a copy of this message
andi Fri Aug 6 20:45:34 2004 EDT Modified files: /ZendEngine2 zend_alloc.h Log: - Commit Derick's patch for allowing Zend to use regular libc memory - allocation functions. Mainly useful in conjunction with tools such as - valgrind which enables us to find bugs we might not find with the - current memory managers boundary protection. http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.h?r1=1.56&r2=1.57&ty=u Index: ZendEngine2/zend_alloc.h diff -u ZendEngine2/zend_alloc.h:1.56 ZendEngine2/zend_alloc.h:1.57 --- ZendEngine2/zend_alloc.h:1.56 Fri Jul 30 16:16:40 2004 +++ ZendEngine2/zend_alloc.h Fri Aug 6 20:45:34 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_alloc.h,v 1.56 2004/07/30 20:16:40 andi Exp $ */ +/* $Id: zend_alloc.h,v 1.57 2004/08/07 00:45:34 andi Exp $ */ #ifndef ZEND_ALLOC_H #define ZEND_ALLOC_H @@ -85,6 +85,10 @@ 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 + +#if USE_ZEND_ALLOC + /* Standard wrapper macros */ #define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) #define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) @@ -123,6 +127,45 @@ #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 + +/* Standard wrapper macros */ +#define emalloc(size) malloc(size) +#define safe_emalloc(nmemb, size, offset) malloc((nmemb) * (size) + (offset)) +#define efree(ptr) free(ptr) +#define ecalloc(nmemb, size) calloc((nmemb), (size)) +#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)) + +/* Relay wrapper macros */ +#define emalloc_rel(size) malloc(size) +#define safe_emalloc_rel(nmemb, size, offset) malloc((nmemb) * (size) + (offset)) +#define efree_rel(ptr) free(ptr) +#define ecalloc_rel(nmemb, size) calloc((nmemb), (size)) +#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)) + +/* Selective persistent/non persistent allocation macros */ +#define pemalloc(size, persistent) malloc(size) +#define pefree(ptr, persistent) free(ptr) +#define pecalloc(nmemb, size, persistent) calloc((nmemb), (size)) +#define perealloc(ptr, size, persistent) realloc((ptr), (size)) +#define perealloc_recoverable(ptr, size, persistent) realloc((ptr), (size)) +#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)) + +#endif ZEND_API int zend_set_memory_limit(unsigned int memory_limit);

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