mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Better debug macros
This commit is contained in:
parent
9eea00c086
commit
aa8b27ba1d
7 changed files with 133 additions and 110 deletions
19
Zend/zend.h
19
Zend/zend.h
|
@ -47,6 +47,23 @@
|
|||
#include "config.unix.h"
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_DEBUG
|
||||
#define ZEND_FILE_LINE_D char *__zend_filename, uint __zend_lineno
|
||||
#define ZEND_FILE_LINE_DC , char *__zend_filename, uint __zend_lineno
|
||||
#define ZEND_FILE_LINE_RELAY_C __zend_filename, __zend_lineno
|
||||
#define ZEND_FILE_LINE_RELAY_CC , __zend_filename, __zend_lineno
|
||||
#define ZEND_FILE_LINE_C __FILE__, __LINE__
|
||||
#define ZEND_FILE_LINE_CC , __FILE__, __LINE__
|
||||
#else
|
||||
#define ZEND_FILE_LINE_D
|
||||
#define ZEND_FILE_LINE_DC
|
||||
#define ZEND_FILE_LINE_RELAY_C
|
||||
#define ZEND_FILE_LINE_RELAY_CC
|
||||
#define ZEND_FILE_LINE_C
|
||||
#define ZEND_FILE_LINE_CC
|
||||
#endif /* ZEND_DEBUG */
|
||||
|
||||
|
||||
#include "zend_errors.h"
|
||||
#include "zend_alloc.h"
|
||||
|
||||
|
@ -192,7 +209,7 @@ ZEND_API extern char *empty_string;
|
|||
ZEND_API extern char *undefined_variable_string;
|
||||
|
||||
#define STR_FREE(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree(ptr); }
|
||||
|
||||
#define STR_FREE_REL(ptr) if (ptr && ptr!=empty_string && ptr!=undefined_variable_string) { efree_rel(ptr); }
|
||||
|
||||
/* output support */
|
||||
#define ZEND_WRITE(str, str_len) zend_write((str), (str_len))
|
||||
|
|
|
@ -46,7 +46,7 @@ static zend_alloc_globals alloc_globals;
|
|||
|
||||
# if MEMORY_LIMIT
|
||||
# if ZEND_DEBUG
|
||||
#define CHECK_MEMORY_LIMIT(s) _CHECK_MEMORY_LIMIT(s,filename,lineno)
|
||||
#define CHECK_MEMORY_LIMIT(s) _CHECK_MEMORY_LIMIT(s ZEND_FILE_LINE_RELAY_CC)
|
||||
# else
|
||||
#define CHECK_MEMORY_LIMIT(s) _CHECK_MEMORY_LIMIT(s,NULL,0)
|
||||
# endif
|
||||
|
@ -97,11 +97,7 @@ static zend_alloc_globals alloc_globals;
|
|||
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void *_emalloc(size_t size, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API void *_emalloc(size_t size)
|
||||
#endif
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p;
|
||||
ALS_FETCH();
|
||||
|
@ -111,8 +107,8 @@ ZEND_API void *_emalloc(size_t size)
|
|||
if ((size < MAX_CACHED_MEMORY) && (AG(cache_count)[size] > 0)) {
|
||||
p = AG(cache)[size][--AG(cache_count)[size]];
|
||||
#if ZEND_DEBUG
|
||||
p->filename = filename;
|
||||
p->lineno = lineno;
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
p->reported = 0;
|
||||
#endif
|
||||
|
@ -138,8 +134,8 @@ ZEND_API void *_emalloc(size_t size)
|
|||
ADD_POINTER_TO_LIST(p);
|
||||
p->size = size;
|
||||
#if ZEND_DEBUG
|
||||
p->filename = filename;
|
||||
p->lineno = lineno;
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
p->reported = 0;
|
||||
*((long *)(((char *) p) + sizeof(mem_header)+size+PLATFORM_PADDING+END_ALIGNMENT(size))) = MEM_BLOCK_END_MAGIC;
|
||||
|
@ -152,17 +148,13 @@ ZEND_API void *_emalloc(size_t size)
|
|||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void _efree(void *ptr, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API void _efree(void *ptr)
|
||||
#endif
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p = (mem_header *) ((char *)ptr - sizeof(mem_header) - PLATFORM_PADDING);
|
||||
ALS_FETCH();
|
||||
|
||||
#if ZEND_DEBUG
|
||||
if (!_mem_block_check(ptr, 1, filename, lineno)) {
|
||||
if (!_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC)) {
|
||||
return;
|
||||
}
|
||||
memset(ptr, 0x5a, p->size);
|
||||
|
@ -188,18 +180,14 @@ ZEND_API void _efree(void *ptr)
|
|||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size)
|
||||
#endif
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC)
|
||||
{
|
||||
void *p;
|
||||
int final_size=size*nmemb;
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
#if ZEND_DEBUG
|
||||
p = _emalloc(final_size,filename,lineno);
|
||||
p = _emalloc(final_size ZEND_FILE_LINE_RELAY_CC);
|
||||
#else
|
||||
p = emalloc(final_size);
|
||||
#endif
|
||||
|
@ -213,11 +201,7 @@ ZEND_API void *_ecalloc(size_t nmemb, size_t size)
|
|||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure)
|
||||
#endif
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p = (mem_header *) ((char *)ptr-sizeof(mem_header)-PLATFORM_PADDING);
|
||||
mem_header *orig = p;
|
||||
|
@ -225,7 +209,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure)
|
|||
|
||||
if (!ptr) {
|
||||
#if ZEND_DEBUG
|
||||
return _emalloc(size, filename, lineno);
|
||||
return _emalloc(size ZEND_FILE_LINE_RELAY_CC);
|
||||
#else
|
||||
return emalloc(size);
|
||||
#endif
|
||||
|
@ -248,8 +232,8 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure)
|
|||
}
|
||||
ADD_POINTER_TO_LIST(p);
|
||||
#if ZEND_DEBUG
|
||||
p->filename = filename;
|
||||
p->lineno = lineno;
|
||||
p->filename = __zend_filename;
|
||||
p->lineno = __zend_lineno;
|
||||
p->magic = MEM_BLOCK_START_MAGIC;
|
||||
*((long *)(((char *) p) + sizeof(mem_header)+size+PLATFORM_PADDING+END_ALIGNMENT(size))) = MEM_BLOCK_END_MAGIC;
|
||||
#endif
|
||||
|
@ -263,11 +247,7 @@ ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure)
|
|||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API char *_estrdup(const char *s, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API char *_estrdup(const char *s)
|
||||
#endif
|
||||
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC)
|
||||
{
|
||||
int length;
|
||||
char *p;
|
||||
|
@ -275,7 +255,7 @@ ZEND_API char *_estrdup(const char *s)
|
|||
length = strlen(s)+1;
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
#if ZEND_DEBUG
|
||||
p = (char *) _emalloc(length,filename,lineno);
|
||||
p = (char *) _emalloc(length ZEND_FILE_LINE_RELAY_CC);
|
||||
#else
|
||||
p = (char *) emalloc(length);
|
||||
#endif
|
||||
|
@ -289,17 +269,13 @@ ZEND_API char *_estrdup(const char *s)
|
|||
}
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API char *_estrndup(const char *s, uint length, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API char *_estrndup(const char *s, uint length)
|
||||
#endif
|
||||
ZEND_API char *_estrndup(const char *s, uint length ZEND_FILE_LINE_DC)
|
||||
{
|
||||
char *p;
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
#if ZEND_DEBUG
|
||||
p = (char *) _emalloc(length+1,filename,lineno);
|
||||
p = (char *) _emalloc(length+1 ZEND_FILE_LINE_RELAY_CC);
|
||||
#else
|
||||
p = (char *) emalloc(length+1);
|
||||
#endif
|
||||
|
@ -424,7 +400,7 @@ void zend_debug_alloc_output(char *format, ...)
|
|||
}
|
||||
|
||||
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p = (mem_header *) ((char *)ptr - sizeof(mem_header) - PLATFORM_PADDING);
|
||||
int no_cache_notice=0;
|
||||
|
@ -442,7 +418,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
if (!silent) {
|
||||
zend_message_dispatcher(ZMSG_LOG_SCRIPT_NAME, NULL);
|
||||
zend_debug_alloc_output("---------------------------------------\n");
|
||||
zend_debug_alloc_output("%s(%d) : Block 0x%0.8lX status:\n", filename, lineno, (long) p);
|
||||
zend_debug_alloc_output("%s(%d) : Block 0x%0.8lX status:\n" ZEND_FILE_LINE_RELAY_CC, (long) p);
|
||||
zend_debug_alloc_output("%10s\t","Beginning: ");
|
||||
}
|
||||
|
||||
|
@ -457,7 +433,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
zend_debug_alloc_output("Freed\n");
|
||||
had_problems=1;
|
||||
} else {
|
||||
return _mem_block_check(ptr, 0, filename, lineno);
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
break;
|
||||
case MEM_BLOCK_CACHED_MAGIC:
|
||||
|
@ -468,7 +444,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
}
|
||||
} else {
|
||||
if (!no_cache_notice) {
|
||||
return _mem_block_check(ptr, 0, filename, lineno);
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -476,7 +452,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
if (!silent) {
|
||||
zend_debug_alloc_output("Overrun (magic=0x%0.8lX, expected=0x%0.8lX)\n", p->magic, MEM_BLOCK_START_MAGIC);
|
||||
} else {
|
||||
return _mem_block_check(ptr, 0, filename, lineno);
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
had_problems=1;
|
||||
valid_beginning=0;
|
||||
|
@ -492,7 +468,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
int i;
|
||||
|
||||
if (silent) {
|
||||
return _mem_block_check(ptr, 0, filename, lineno);
|
||||
return _mem_block_check(ptr, 0 ZEND_FILE_LINE_RELAY_CC);
|
||||
}
|
||||
had_problems=1;
|
||||
overflow_ptr = ((char *) p)+sizeof(mem_header)+p->size+PLATFORM_PADDING;
|
||||
|
@ -534,7 +510,7 @@ ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno)
|
|||
}
|
||||
|
||||
|
||||
ZEND_API void _full_mem_check(int silent, char *filename, uint lineno)
|
||||
ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p;
|
||||
int errors=0;
|
||||
|
@ -544,31 +520,27 @@ ZEND_API void _full_mem_check(int silent, char *filename, uint lineno)
|
|||
|
||||
|
||||
zend_debug_alloc_output("------------------------------------------------\n");
|
||||
zend_debug_alloc_output("Full Memory Check at %s:%d\n", filename, lineno);
|
||||
zend_debug_alloc_output("Full Memory Check at %s:%d\n" ZEND_FILE_LINE_RELAY_CC);
|
||||
|
||||
while (p) {
|
||||
if (!_mem_block_check((void *)((char *)p + sizeof(mem_header) + PLATFORM_PADDING), (silent?2:3), filename, lineno)) {
|
||||
if (!_mem_block_check((void *)((char *)p + sizeof(mem_header) + PLATFORM_PADDING), (silent?2:3) ZEND_FILE_LINE_RELAY_CC)) {
|
||||
errors++;
|
||||
}
|
||||
p = p->pNext;
|
||||
}
|
||||
zend_debug_alloc_output("End of full memory check %s:%d (%d errors)\n", filename, lineno, errors);
|
||||
zend_debug_alloc_output("End of full memory check %s:%d (%d errors)\n" ZEND_FILE_LINE_RELAY_CC, errors);
|
||||
zend_debug_alloc_output("------------------------------------------------\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void _persist_alloc(void *ptr, char *filename, uint lineno)
|
||||
#else
|
||||
ZEND_API void _persist_alloc(void *ptr)
|
||||
#endif
|
||||
ZEND_API void _persist_alloc(void *ptr ZEND_FILE_LINE_DC)
|
||||
{
|
||||
mem_header *p = (mem_header *) ((char *)ptr-sizeof(mem_header)-PLATFORM_PADDING);
|
||||
ALS_FETCH();
|
||||
|
||||
#if ZEND_DEBUG
|
||||
_mem_block_check(ptr, 1, filename, lineno);
|
||||
_mem_block_check(ptr, 1 ZEND_FILE_LINE_RELAY_CC);
|
||||
#endif
|
||||
|
||||
HANDLE_BLOCK_INTERRUPTIONS();
|
||||
|
|
|
@ -58,40 +58,35 @@ ZEND_API char *zend_strndup(const char *s, unsigned int length);
|
|||
|
||||
BEGIN_EXTERN_C()
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API void *_emalloc(size_t size, char *filename, uint lineno);
|
||||
ZEND_API void _efree(void *ptr, char *filename, uint lineno);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size, char *filename, uint lineno);
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure, char *filename, uint lineno);
|
||||
ZEND_API char *_estrdup(const char *s, char *filename, uint lineno);
|
||||
ZEND_API char *_estrndup(const char *s, unsigned int length, char *filename, uint lineno);
|
||||
ZEND_API void _persist_alloc(void *ptr, char *filename, uint lineno);
|
||||
#define emalloc(size) _emalloc((size),__FILE__,__LINE__)
|
||||
#define efree(ptr) _efree((ptr),__FILE__,__LINE__)
|
||||
#define ecalloc(nmemb,size) _ecalloc((nmemb),(size),__FILE__,__LINE__)
|
||||
#define erealloc(ptr,size) _erealloc((ptr),(size),0,__FILE__,__LINE__)
|
||||
#define erealloc_recoverable(ptr,size) _erealloc((ptr),(size),1,__FILE__,__LINE__)
|
||||
#define estrdup(s) _estrdup((s),__FILE__,__LINE__)
|
||||
#define estrndup(s,length) _estrndup((s),(length),__FILE__,__LINE__)
|
||||
#define persist_alloc(p) _persist_alloc((p),__FILE__,__LINE__)
|
||||
#else
|
||||
ZEND_API void *_emalloc(size_t size);
|
||||
ZEND_API void _efree(void *ptr);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size);
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure);
|
||||
ZEND_API char *_estrdup(const char *s);
|
||||
ZEND_API char *_estrndup(const char *s, unsigned int length);
|
||||
ZEND_API void _persist_alloc(void *ptr);
|
||||
#define emalloc(size) _emalloc((size))
|
||||
#define efree(ptr) _efree((ptr))
|
||||
#define ecalloc(nmemb,size) _ecalloc((nmemb),(size))
|
||||
#define erealloc(ptr,size) _erealloc((ptr),(size),0)
|
||||
#define erealloc_recoverable(ptr,size) _erealloc((ptr),(size),1)
|
||||
#define estrdup(s) _estrdup((s))
|
||||
#define estrndup(s,length) _estrndup((s),(length))
|
||||
#define persist_alloc(p) _persist_alloc((p))
|
||||
#endif
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC);
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC);
|
||||
ZEND_API void *_erealloc(void *ptr, size_t size, int allow_failure ZEND_FILE_LINE_DC);
|
||||
ZEND_API char *_estrdup(const char *s ZEND_FILE_LINE_DC);
|
||||
ZEND_API char *_estrndup(const char *s, unsigned int length ZEND_FILE_LINE_DC);
|
||||
ZEND_API void _persist_alloc(void *ptr ZEND_FILE_LINE_DC);
|
||||
|
||||
/* Standard wrapper macros */
|
||||
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC)
|
||||
#define efree(ptr) _efree((ptr) ZEND_FILE_LINE_CC)
|
||||
#define ecalloc(nmemb,size) _ecalloc((nmemb),(size) ZEND_FILE_LINE_CC)
|
||||
#define erealloc(ptr,size) _erealloc((ptr),(size),0 ZEND_FILE_LINE_CC)
|
||||
#define erealloc_recoverable(ptr,size) _erealloc((ptr),(size),1 ZEND_FILE_LINE_CC)
|
||||
#define estrdup(s) _estrdup((s) ZEND_FILE_LINE_CC)
|
||||
#define estrndup(s,length) _estrndup((s),(length) ZEND_FILE_LINE_CC)
|
||||
#define persist_alloc(p) _persist_alloc((p) ZEND_FILE_LINE_CC)
|
||||
|
||||
/* Relay wrapper macros */
|
||||
#define emalloc_rel(size) _emalloc((size) ZEND_FILE_LINE_RELAY_CC)
|
||||
#define efree_rel(ptr) _efree((ptr) ZEND_FILE_LINE_RELAY_CC)
|
||||
#define ecalloc_rel(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_RELAY_CC)
|
||||
#define erealloc_rel(ptr, size) _erealloc((ptr), (size), 0 ZEND_FILE_LINE_RELAY_CC)
|
||||
#define erealloc_recoverable_rel(ptr, size) _erealloc((ptr), (size), 1 ZEND_FILE_LINE_RELAY_CC)
|
||||
#define estrdup_rel(s) _estrdup((s) ZEND_FILE_LINE_RELAY_CC)
|
||||
#define estrndup_rel(s, length) _estrndup((s) ZEND_FILE_LINE_RELAY_CC)
|
||||
#define persist_alloc_rel(p) _persist_alloc((p) ZEND_FILE_LINE_RELAY_CC)
|
||||
|
||||
/* Selective persistent/non persistent allocation macros */
|
||||
#define pemalloc(size,persistent) ((persistent)?malloc(size):emalloc(size))
|
||||
#define pefree(ptr,persistent) ((persistent)?free(ptr):efree(ptr))
|
||||
#define pecalloc(nmemb,size,persistent) ((persistent)?calloc((nmemb),(size)):ecalloc((nmemb),(size)))
|
||||
|
@ -108,11 +103,11 @@ ZEND_API void start_memory_manager(void);
|
|||
ZEND_API void shutdown_memory_manager(int silent, int clean_cache);
|
||||
|
||||
#if ZEND_DEBUG
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent, char *filename, int lineno);
|
||||
ZEND_API void _full_mem_check(int silent, char *filename, uint lineno);
|
||||
#define mem_block_check(ptr, silent) _mem_block_check(ptr, silent, __FILE__, __LINE__)
|
||||
#define mem_block_check(ptr, silent) _mem_block_check(ptr, silent, __FILE__, __LINE__)
|
||||
#define full_mem_check(silent) _full_mem_check(silent, __FILE__, __LINE__)
|
||||
ZEND_API int _mem_block_check(void *ptr, int silent ZEND_FILE_LINE_DC);
|
||||
ZEND_API void _full_mem_check(int silent ZEND_FILE_LINE_DC);
|
||||
#define mem_block_check(ptr, silent) _mem_block_check(ptr, silent ZEND_FILE_LINE_CC)
|
||||
#define mem_block_check(ptr, silent) _mem_block_check(ptr, silent ZEND_FILE_LINE_CC)
|
||||
#define full_mem_check(silent) _full_mem_check(silent ZEND_FILE_LINE_CC)
|
||||
#else
|
||||
#define mem_block_check(type, ptr, silent)
|
||||
#define full_mem_check(silent)
|
||||
|
|
|
@ -203,7 +203,7 @@ ZEND_API inline void safe_free_zval_ptr(zval *p)
|
|||
}
|
||||
|
||||
|
||||
ZEND_API int zval_ptr_dtor(zval **zval_ptr)
|
||||
ZEND_API int _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
|
||||
{
|
||||
int locked = (*zval_ptr)->EA.locks;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ ZEND_API inline void var_uninit(zval *var)
|
|||
}
|
||||
|
||||
|
||||
ZEND_API int zval_dtor(zval *zvalue)
|
||||
ZEND_API int _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
{
|
||||
if (zvalue->type==IS_LONG) {
|
||||
return 1;
|
||||
|
@ -59,20 +59,20 @@ ZEND_API int zval_dtor(zval *zvalue)
|
|||
switch(zvalue->type) {
|
||||
case IS_STRING:
|
||||
case IS_CONSTANT:
|
||||
STR_FREE(zvalue->value.str.val);
|
||||
STR_FREE_REL(zvalue->value.str.val);
|
||||
break;
|
||||
case IS_ARRAY: {
|
||||
ELS_FETCH();
|
||||
|
||||
if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) {
|
||||
zend_hash_destroy(zvalue->value.ht);
|
||||
efree(zvalue->value.ht);
|
||||
efree_rel(zvalue->value.ht);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case IS_OBJECT:
|
||||
zend_hash_destroy(zvalue->value.obj.properties);
|
||||
efree(zvalue->value.obj.properties);
|
||||
efree_rel(zvalue->value.obj.properties);
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
/* destroy resource */
|
||||
|
@ -97,7 +97,7 @@ void zval_add_ref(zval **p)
|
|||
|
||||
|
||||
|
||||
ZEND_API int zval_copy_ctor(zval *zvalue)
|
||||
ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC)
|
||||
{
|
||||
switch (zvalue->type) {
|
||||
case IS_RESOURCE:
|
||||
|
@ -153,6 +153,27 @@ ZEND_API int zend_print_variable(zval *var)
|
|||
}
|
||||
|
||||
|
||||
#ifdef ZEND_DEBUG
|
||||
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue)
|
||||
{
|
||||
return zval_copy_ctor(zvalue);
|
||||
}
|
||||
|
||||
|
||||
ZEND_API int _zval_dtor_wrapper(zval *zvalue)
|
||||
{
|
||||
return zval_dtor(zvalue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ZEND_API int _zval_ptr_dtor_wrapper(zval **zval_ptr)
|
||||
{
|
||||
return zval_ptr_dtor(zval_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
|
|
@ -25,16 +25,34 @@
|
|||
ZEND_API int zend_print_variable(zval *var);
|
||||
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API int zval_copy_ctor(zval *zvalue);
|
||||
ZEND_API int zval_dtor(zval *zvalue);
|
||||
ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC);
|
||||
ZEND_API int _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
|
||||
#define zval_copy_ctor(zvalue) _zval_copy_ctor((zvalue) ZEND_FILE_LINE_CC)
|
||||
#define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC)
|
||||
#define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
|
||||
|
||||
#ifdef ZEND_DEBUG
|
||||
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue);
|
||||
ZEND_API int _zval_dtor_wrapper(zval *zvalue);
|
||||
ZEND_API int _zval_ptr_dtor_wrapper(zval **zval_ptr);
|
||||
#define zval_copy_ctor_wrapper _zval_copy_ctor_wrapper
|
||||
#define zval_dtor_wrapper _zval_dtor_wrapper
|
||||
#define zval_ptr_dtor_wrapper _zval_ptr_dtor_wrapper
|
||||
#else
|
||||
#define zval_copy_ctor_wrapper _zval_copy_ctor
|
||||
#define zval_dtor_wrapper _zval_dtor
|
||||
#define zval_ptr_dtor_wrapper _zval_ptr_dtor
|
||||
#endif
|
||||
|
||||
END_EXTERN_C()
|
||||
|
||||
ZEND_API int zval_ptr_dtor(zval **zval_ptr);
|
||||
|
||||
void zval_add_ref(zval **p);
|
||||
|
||||
#define PVAL_DESTRUCTOR (int (*)(void *)) zval_dtor
|
||||
#define PVAL_PTR_DTOR (int (*)(void *)) zval_ptr_dtor
|
||||
#define PVAL_COPY_CTOR (void (*)(void *)) zval_copy_ctor
|
||||
#define PVAL_DESTRUCTOR (int (*)(void *)) zval_dtor_wrapper
|
||||
#define PVAL_PTR_DTOR (int (*)(void *)) zval_ptr_dtor_wrapper
|
||||
#define PVAL_COPY_CTOR (void (*)(void *)) zval_copy_ctor_wrapper
|
||||
|
||||
ZEND_API void var_reset(zval *var);
|
||||
ZEND_API void var_uninit(zval *var);
|
||||
|
|
|
@ -111,7 +111,7 @@ PHP_FUNCTION(get_browser)
|
|||
if (zend_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
|
||||
break;
|
||||
}
|
||||
zend_hash_merge(return_value->value.ht,agent->value.ht,(void (*)(void *pData)) pval_copy_constructor, (void *) &tmp, sizeof(pval), 0);
|
||||
zend_hash_merge(return_value->value.ht, agent->value.ht, PVAL_COPY_CTOR, (void *) &tmp, sizeof(pval), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue