Permalink
Browse files

Merge branch 'PHP-5.4' into PHP-5.5

Conflicts:
	ext/mysqlnd/mysqlnd_alloc.c
  • Loading branch information...
2 parents 2768315 + ae9ba08 commit ec012c1b75a46ebc9a685597d8bcd74c4c0fa0c4 Andrey Hristov committed Dec 19, 2012
Showing with 95 additions and 42 deletions.
  1. +95 −42 ext/mysqlnd/mysqlnd_alloc.c
View
@@ -81,11 +81,14 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
#if PHP_DEBUG
/* -1 is also "true" */
@@ -118,10 +121,14 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno, persistent);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
#if PHP_DEBUG
/* -1 is also "true" */
@@ -157,10 +164,14 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
#if PHP_DEBUG
@@ -194,10 +205,13 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
#if PHP_DEBUG
long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno, persistent);
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
#if PHP_DEBUG
/* -1 is also "true" */
@@ -234,10 +248,14 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size);
#if PHP_DEBUG
@@ -271,10 +289,14 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
#if PHP_DEBUG
long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent);
#if PHP_DEBUG
@@ -307,10 +329,14 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_efree_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
if (ptr) {
@@ -334,10 +360,14 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pefree_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p persistent=%u", ptr, persistent);
if (ptr) {
@@ -365,10 +395,14 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
#if PHP_DEBUG
/* -1 is also "true" */
@@ -400,10 +434,14 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
#if PHP_DEBUG
/* -1 is also "true" */
@@ -435,10 +473,14 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
#if PHP_DEBUG
long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
#endif
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
@@ -470,10 +512,14 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D)
{
size_t free_amount = 0;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_free_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
if (ptr) {
@@ -501,10 +547,14 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t length, zend_bool persi
{
char * ret;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pestrndup_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
ret = (persistent) ? __zend_malloc(REAL_SIZE(length + 1)) : _emalloc(REAL_SIZE(length + 1) ZEND_FILE_LINE_CC ZEND_FILE_LINE_ORIG_RELAY_CC);
@@ -535,10 +585,13 @@ char * _mysqlnd_pestrdup(const char * const ptr, zend_bool persistent MYSQLND_ME
smart_str tmp_str = {0, 0, 0};
const char * p = ptr;
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
- char * fn = NULL;
TRACE_ALLOC_ENTER(mysqlnd_pestrdup_name);
- TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
- (fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+#if PHP_DEBUG
+ {
+ char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
+ TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
+ }
+#endif
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
do {
smart_str_appendc(&tmp_str, *p);

0 comments on commit ec012c1

Please sign in to comment.