Skip to content

Commit ec012c1

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
Conflicts: ext/mysqlnd/mysqlnd_alloc.c
2 parents 2768315 + ae9ba08 commit ec012c1

File tree

1 file changed

+95
-42
lines changed

1 file changed

+95
-42
lines changed

ext/mysqlnd/mysqlnd_alloc.c

Lines changed: 95 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
8181
#if PHP_DEBUG
8282
long * threshold = &MYSQLND_G(debug_emalloc_fail_threshold);
8383
#endif
84-
char * fn = NULL;
8584
TRACE_ALLOC_ENTER(mysqlnd_emalloc_name);
8685

87-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
88-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
86+
#if PHP_DEBUG
87+
{
88+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
89+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
90+
}
91+
#endif
8992

9093
#if PHP_DEBUG
9194
/* -1 is also "true" */
@@ -118,10 +121,14 @@ void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
118121
#if PHP_DEBUG
119122
long * threshold = persistent? &MYSQLND_G(debug_malloc_fail_threshold):&MYSQLND_G(debug_emalloc_fail_threshold);
120123
#endif
121-
char * fn = NULL;
122124
TRACE_ALLOC_ENTER(mysqlnd_pemalloc_name);
123-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
124-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno, persistent);
125+
126+
#if PHP_DEBUG
127+
{
128+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
129+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
130+
}
131+
#endif
125132

126133
#if PHP_DEBUG
127134
/* -1 is also "true" */
@@ -157,10 +164,14 @@ void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
157164
#if PHP_DEBUG
158165
long * threshold = &MYSQLND_G(debug_ecalloc_fail_threshold);
159166
#endif
160-
char * fn = NULL;
161167
TRACE_ALLOC_ENTER(mysqlnd_ecalloc_name);
162-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
163-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
168+
169+
#if PHP_DEBUG
170+
{
171+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
172+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
173+
}
174+
#endif
164175
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(FALSE TSRMLS_CC));
165176

166177
#if PHP_DEBUG
@@ -194,10 +205,13 @@ void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persistent M
194205
#if PHP_DEBUG
195206
long * threshold = persistent? &MYSQLND_G(debug_calloc_fail_threshold):&MYSQLND_G(debug_ecalloc_fail_threshold);
196207
#endif
197-
char * fn = NULL;
198208
TRACE_ALLOC_ENTER(mysqlnd_pecalloc_name);
199-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d persistent=%u",
200-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno, persistent);
209+
#if PHP_DEBUG
210+
{
211+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
212+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
213+
}
214+
#endif
201215

202216
#if PHP_DEBUG
203217
/* -1 is also "true" */
@@ -234,10 +248,14 @@ void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
234248
#if PHP_DEBUG
235249
long * threshold = &MYSQLND_G(debug_erealloc_fail_threshold);
236250
#endif
237-
char * fn = NULL;
238251
TRACE_ALLOC_ENTER(mysqlnd_erealloc_name);
239-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
240-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
252+
253+
#if PHP_DEBUG
254+
{
255+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
256+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
257+
}
258+
#endif
241259
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu, new_size=%lu", ptr, old_size, new_size);
242260

243261
#if PHP_DEBUG
@@ -271,10 +289,14 @@ void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persistent MYSQL
271289
#if PHP_DEBUG
272290
long * threshold = persistent? &MYSQLND_G(debug_realloc_fail_threshold):&MYSQLND_G(debug_erealloc_fail_threshold);
273291
#endif
274-
char * fn = NULL;
275292
TRACE_ALLOC_ENTER(mysqlnd_perealloc_name);
276-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
277-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
293+
294+
#if PHP_DEBUG
295+
{
296+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
297+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
298+
}
299+
#endif
278300
TRACE_ALLOC_INF_FMT("ptr=%p old_size=%lu new_size=%lu persistent=%u", ptr, old_size, new_size, persistent);
279301

280302
#if PHP_DEBUG
@@ -307,10 +329,14 @@ void _mysqlnd_efree(void *ptr MYSQLND_MEM_D)
307329
{
308330
size_t free_amount = 0;
309331
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
310-
char * fn = NULL;
311332
TRACE_ALLOC_ENTER(mysqlnd_efree_name);
312-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
313-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
333+
334+
#if PHP_DEBUG
335+
{
336+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
337+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
338+
}
339+
#endif
314340
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
315341

316342
if (ptr) {
@@ -334,10 +360,14 @@ void _mysqlnd_pefree(void *ptr, zend_bool persistent MYSQLND_MEM_D)
334360
{
335361
size_t free_amount = 0;
336362
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
337-
char * fn = NULL;
338363
TRACE_ALLOC_ENTER(mysqlnd_pefree_name);
339-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
340-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
364+
365+
#if PHP_DEBUG
366+
{
367+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
368+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
369+
}
370+
#endif
341371
TRACE_ALLOC_INF_FMT("ptr=%p persistent=%u", ptr, persistent);
342372

343373
if (ptr) {
@@ -365,10 +395,14 @@ void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
365395
#if PHP_DEBUG
366396
long * threshold = &MYSQLND_G(debug_malloc_fail_threshold);
367397
#endif
368-
char * fn = NULL;
369398
TRACE_ALLOC_ENTER(mysqlnd_malloc_name);
370-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
371-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
399+
400+
#if PHP_DEBUG
401+
{
402+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
403+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
404+
}
405+
#endif
372406

373407
#if PHP_DEBUG
374408
/* -1 is also "true" */
@@ -400,10 +434,14 @@ void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
400434
#if PHP_DEBUG
401435
long * threshold = &MYSQLND_G(debug_calloc_fail_threshold);
402436
#endif
403-
char * fn = NULL;
404437
TRACE_ALLOC_ENTER(mysqlnd_calloc_name);
405-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
406-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
438+
439+
#if PHP_DEBUG
440+
{
441+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
442+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
443+
}
444+
#endif
407445

408446
#if PHP_DEBUG
409447
/* -1 is also "true" */
@@ -435,10 +473,14 @@ void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
435473
#if PHP_DEBUG
436474
long * threshold = &MYSQLND_G(debug_realloc_fail_threshold);
437475
#endif
438-
char * fn = NULL;
439476
TRACE_ALLOC_ENTER(mysqlnd_realloc_name);
440-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
441-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
477+
478+
#if PHP_DEBUG
479+
{
480+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
481+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
482+
}
483+
#endif
442484
TRACE_ALLOC_INF_FMT("ptr=%p new_size=%lu ", new_size, ptr);
443485
TRACE_ALLOC_INF_FMT("before: %lu", zend_memory_usage(TRUE TSRMLS_CC));
444486

@@ -470,10 +512,14 @@ void _mysqlnd_free(void *ptr MYSQLND_MEM_D)
470512
{
471513
size_t free_amount = 0;
472514
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
473-
char * fn = NULL;
474515
TRACE_ALLOC_ENTER(mysqlnd_free_name);
475-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
476-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
516+
517+
#if PHP_DEBUG
518+
{
519+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
520+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
521+
}
522+
#endif
477523
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
478524

479525
if (ptr) {
@@ -501,10 +547,14 @@ char * _mysqlnd_pestrndup(const char * const ptr, size_t length, zend_bool persi
501547
{
502548
char * ret;
503549
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
504-
char * fn = NULL;
505550
TRACE_ALLOC_ENTER(mysqlnd_pestrndup_name);
506-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
507-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
551+
552+
#if PHP_DEBUG
553+
{
554+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
555+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
556+
}
557+
#endif
508558
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
509559

510560
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
535585
smart_str tmp_str = {0, 0, 0};
536586
const char * p = ptr;
537587
zend_bool collect_memory_statistics = MYSQLND_G(collect_memory_statistics);
538-
char * fn = NULL;
539588
TRACE_ALLOC_ENTER(mysqlnd_pestrdup_name);
540-
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d",
541-
(fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR))? fn + 1:__zend_orig_filename, __zend_orig_lineno);
589+
#if PHP_DEBUG
590+
{
591+
char * fn = strrchr(__zend_orig_filename, PHP_DIR_SEPARATOR);
592+
TRACE_ALLOC_INF_FMT("file=%-15s line=%4d", fn? fn + 1:__zend_orig_filename, __zend_orig_lineno);
593+
}
594+
#endif
542595
TRACE_ALLOC_INF_FMT("ptr=%p", ptr);
543596
do {
544597
smart_str_appendc(&tmp_str, *p);

0 commit comments

Comments
 (0)