@@ -82,26 +82,22 @@ static void * _mysqlnd_emalloc(size_t size MYSQLND_MEM_D)
82
82
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
83
83
#if PHP_DEBUG
84
84
zend_long * threshold = & MYSQLND_G (debug_emalloc_fail_threshold );
85
- #endif
86
85
TRACE_ALLOC_ENTER (mysqlnd_emalloc_name );
87
86
88
- #if PHP_DEBUG
89
87
{
90
88
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
91
89
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
92
90
}
93
- #endif
94
91
95
- #if PHP_DEBUG
96
- /* -1 is also "true" */
97
- if (* threshold ) {
98
- #endif
92
+ if (* threshold == 0 ) {
93
+ ret = NULL ;
94
+ } else {
99
95
ret = emalloc_rel (REAL_SIZE (size ));
100
- #if PHP_DEBUG
101
96
-- * threshold ;
102
- } else if (* threshold == 0 ) {
103
- ret = NULL ;
104
97
}
98
+ #else
99
+ TRACE_ALLOC_ENTER (mysqlnd_emalloc_name );
100
+ ret = emalloc_rel (REAL_SIZE (size ));
105
101
#endif
106
102
107
103
TRACE_ALLOC_INF_FMT ("size=%lu ptr=%p" , size , ret );
@@ -122,26 +118,22 @@ static void * _mysqlnd_pemalloc(size_t size, zend_bool persistent MYSQLND_MEM_D)
122
118
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
123
119
#if PHP_DEBUG
124
120
zend_long * threshold = persistent ? & MYSQLND_G (debug_malloc_fail_threshold ):& MYSQLND_G (debug_emalloc_fail_threshold );
125
- #endif
126
121
TRACE_ALLOC_ENTER (mysqlnd_pemalloc_name );
127
122
128
- #if PHP_DEBUG
129
123
{
130
124
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
131
125
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
132
126
}
133
- #endif
134
127
135
- #if PHP_DEBUG
136
- /* -1 is also "true" */
137
- if (* threshold ) {
138
- #endif
128
+ if (* threshold == 0 ) {
129
+ ret = NULL ;
130
+ } else {
139
131
ret = pemalloc_rel (REAL_SIZE (size ), persistent );
140
- #if PHP_DEBUG
141
132
-- * threshold ;
142
- } else if (* threshold == 0 ) {
143
- ret = NULL ;
144
133
}
134
+ #else
135
+ TRACE_ALLOC_ENTER (mysqlnd_pemalloc_name );
136
+ ret = pemalloc_rel (REAL_SIZE (size ), persistent );
145
137
#endif
146
138
147
139
TRACE_ALLOC_INF_FMT ("size=%lu ptr=%p persistent=%u" , size , ret , persistent );
@@ -163,29 +155,26 @@ static void * _mysqlnd_ecalloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
163
155
{
164
156
void * ret ;
165
157
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
166
- #if PHP_DEBUG
167
158
zend_long * threshold = & MYSQLND_G (debug_ecalloc_fail_threshold );
168
- #endif
159
+ #if PHP_DEBUG
169
160
TRACE_ALLOC_ENTER (mysqlnd_ecalloc_name );
170
161
171
- #if PHP_DEBUG
172
162
{
173
163
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
174
164
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
175
165
}
176
- #endif
177
166
TRACE_ALLOC_INF_FMT ("before: %lu" , zend_memory_usage (FALSE));
178
167
179
- #if PHP_DEBUG
180
- /* -1 is also "true" */
181
- if (* threshold ) {
182
- #endif
168
+ if (* threshold == 0 ) {
169
+ ret = NULL ;
170
+ } else {
183
171
ret = ecalloc_rel (nmemb , REAL_SIZE (size ));
184
- #if PHP_DEBUG
185
172
-- * threshold ;
186
- } else if (* threshold == 0 ) {
187
- ret = NULL ;
188
173
}
174
+ #else
175
+ TRACE_ALLOC_ENTER (mysqlnd_ecalloc_name );
176
+ TRACE_ALLOC_INF_FMT ("before: %lu" , zend_memory_usage (FALSE));
177
+ ret = ecalloc_rel (nmemb , REAL_SIZE (size ));
189
178
#endif
190
179
191
180
TRACE_ALLOC_INF_FMT ("after : %lu" , zend_memory_usage (FALSE));
@@ -206,25 +195,21 @@ static void * _mysqlnd_pecalloc(unsigned int nmemb, size_t size, zend_bool persi
206
195
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
207
196
#if PHP_DEBUG
208
197
zend_long * threshold = persistent ? & MYSQLND_G (debug_calloc_fail_threshold ):& MYSQLND_G (debug_ecalloc_fail_threshold );
209
- #endif
210
198
TRACE_ALLOC_ENTER (mysqlnd_pecalloc_name );
211
- #if PHP_DEBUG
212
199
{
213
200
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
214
201
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
215
202
}
216
- #endif
217
203
218
- #if PHP_DEBUG
219
- /* -1 is also "true" */
220
- if (* threshold ) {
221
- #endif
204
+ if (* threshold == 0 ) {
205
+ ret = NULL ;
206
+ } else {
222
207
ret = pecalloc_rel (nmemb , REAL_SIZE (size ), persistent );
223
- #if PHP_DEBUG
224
208
-- * threshold ;
225
- } else if (* threshold == 0 ) {
226
- ret = NULL ;
227
209
}
210
+ #else
211
+ TRACE_ALLOC_ENTER (mysqlnd_pecalloc_name );
212
+ ret = pecalloc_rel (nmemb , REAL_SIZE (size ), persistent );
228
213
#endif
229
214
230
215
TRACE_ALLOC_INF_FMT ("size=%lu ptr=%p" , size , ret );
@@ -249,27 +234,24 @@ static void * _mysqlnd_erealloc(void *ptr, size_t new_size MYSQLND_MEM_D)
249
234
size_t old_size = collect_memory_statistics && ptr ? * (size_t * ) (((char * )ptr ) - sizeof (size_t )) : 0 ;
250
235
#if PHP_DEBUG
251
236
zend_long * threshold = & MYSQLND_G (debug_erealloc_fail_threshold );
252
- #endif
253
237
TRACE_ALLOC_ENTER (mysqlnd_erealloc_name );
254
238
255
- #if PHP_DEBUG
256
239
{
257
240
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
258
241
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
259
242
}
260
- #endif
261
243
TRACE_ALLOC_INF_FMT ("ptr=%p old_size=%lu, new_size=%lu" , ptr , old_size , new_size );
262
244
263
- #if PHP_DEBUG
264
- /* -1 is also "true" */
265
- if (* threshold ) {
266
- #endif
245
+ if (* threshold == 0 ) {
246
+ ret = NULL ;
247
+ } else {
267
248
ret = erealloc_rel (REAL_PTR (ptr ), REAL_SIZE (new_size ));
268
- #if PHP_DEBUG
269
249
-- * threshold ;
270
- } else if (* threshold == 0 ) {
271
- ret = NULL ;
272
250
}
251
+ #else
252
+ TRACE_ALLOC_ENTER (mysqlnd_erealloc_name );
253
+ TRACE_ALLOC_INF_FMT ("ptr=%p old_size=%lu, new_size=%lu" , ptr , old_size , new_size );
254
+ ret = erealloc_rel (REAL_PTR (ptr ), REAL_SIZE (new_size ));
273
255
#endif
274
256
275
257
TRACE_ALLOC_INF_FMT ("new_ptr=%p" , (char * )ret );
@@ -290,27 +272,24 @@ static void * _mysqlnd_perealloc(void *ptr, size_t new_size, zend_bool persisten
290
272
size_t old_size = collect_memory_statistics && ptr ? * (size_t * ) (((char * )ptr ) - sizeof (size_t )) : 0 ;
291
273
#if PHP_DEBUG
292
274
zend_long * threshold = persistent ? & MYSQLND_G (debug_realloc_fail_threshold ):& MYSQLND_G (debug_erealloc_fail_threshold );
293
- #endif
294
275
TRACE_ALLOC_ENTER (mysqlnd_perealloc_name );
295
276
296
- #if PHP_DEBUG
297
277
{
298
278
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
299
279
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
300
280
}
301
- #endif
302
281
TRACE_ALLOC_INF_FMT ("ptr=%p old_size=%lu new_size=%lu persistent=%u" , ptr , old_size , new_size , persistent );
303
282
304
- #if PHP_DEBUG
305
- /* -1 is also "true" */
306
- if (* threshold ) {
307
- #endif
283
+ if (* threshold == 0 ) {
284
+ ret = NULL ;
285
+ } else {
308
286
ret = perealloc_rel (REAL_PTR (ptr ), REAL_SIZE (new_size ), persistent );
309
- #if PHP_DEBUG
310
287
-- * threshold ;
311
- } else if (* threshold == 0 ) {
312
- ret = NULL ;
313
288
}
289
+ #else
290
+ TRACE_ALLOC_ENTER (mysqlnd_perealloc_name );
291
+ TRACE_ALLOC_INF_FMT ("ptr=%p old_size=%lu new_size=%lu persistent=%u" , ptr , old_size , new_size , persistent );
292
+ ret = perealloc_rel (REAL_PTR (ptr ), REAL_SIZE (new_size ), persistent );
314
293
#endif
315
294
316
295
TRACE_ALLOC_INF_FMT ("new_ptr=%p" , (char * )ret );
@@ -396,26 +375,22 @@ static void * _mysqlnd_malloc(size_t size MYSQLND_MEM_D)
396
375
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
397
376
#if PHP_DEBUG
398
377
zend_long * threshold = & MYSQLND_G (debug_malloc_fail_threshold );
399
- #endif
400
378
TRACE_ALLOC_ENTER (mysqlnd_malloc_name );
401
379
402
- #if PHP_DEBUG
403
380
{
404
381
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
405
382
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
406
383
}
407
- #endif
408
384
409
- #if PHP_DEBUG
410
- /* -1 is also "true" */
411
- if (* threshold ) {
412
- #endif
385
+ if (* threshold == 0 ) {
386
+ ret = NULL ;
387
+ } else {
413
388
ret = malloc (REAL_SIZE (size ));
414
- #if PHP_DEBUG
415
389
-- * threshold ;
416
- } else if (* threshold == 0 ) {
417
- ret = NULL ;
418
390
}
391
+ #else
392
+ TRACE_ALLOC_ENTER (mysqlnd_malloc_name );
393
+ ret = malloc (REAL_SIZE (size ));
419
394
#endif
420
395
421
396
TRACE_ALLOC_INF_FMT ("size=%lu ptr=%p" , size , ret );
@@ -435,26 +410,22 @@ static void * _mysqlnd_calloc(unsigned int nmemb, size_t size MYSQLND_MEM_D)
435
410
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
436
411
#if PHP_DEBUG
437
412
zend_long * threshold = & MYSQLND_G (debug_calloc_fail_threshold );
438
- #endif
439
413
TRACE_ALLOC_ENTER (mysqlnd_calloc_name );
440
414
441
- #if PHP_DEBUG
442
415
{
443
416
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
444
417
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
445
418
}
446
- #endif
447
419
448
- #if PHP_DEBUG
449
- /* -1 is also "true" */
450
- if (* threshold ) {
451
- #endif
420
+ if (* threshold == 0 ) {
421
+ ret = NULL ;
422
+ } else {
452
423
ret = calloc (nmemb , REAL_SIZE (size ));
453
- #if PHP_DEBUG
454
424
-- * threshold ;
455
- } else if (* threshold == 0 ) {
456
- ret = NULL ;
457
425
}
426
+ #else
427
+ TRACE_ALLOC_ENTER (mysqlnd_calloc_name );
428
+ ret = calloc (nmemb , REAL_SIZE (size ));
458
429
#endif
459
430
460
431
TRACE_ALLOC_INF_FMT ("size=%lu ptr=%p" , size , ret );
@@ -474,28 +445,26 @@ static void * _mysqlnd_realloc(void *ptr, size_t new_size MYSQLND_MEM_D)
474
445
zend_bool collect_memory_statistics = MYSQLND_G (collect_memory_statistics );
475
446
#if PHP_DEBUG
476
447
zend_long * threshold = & MYSQLND_G (debug_realloc_fail_threshold );
477
- #endif
478
448
TRACE_ALLOC_ENTER (mysqlnd_realloc_name );
479
449
480
- #if PHP_DEBUG
481
450
{
482
451
char * fn = strrchr (__zend_filename , PHP_DIR_SEPARATOR );
483
452
TRACE_ALLOC_INF_FMT ("file=%-15s line=%4d" , fn ? fn + 1 :__zend_filename , __zend_lineno );
484
453
}
485
- #endif
486
454
TRACE_ALLOC_INF_FMT ("ptr=%p new_size=%lu " , new_size , ptr );
487
455
TRACE_ALLOC_INF_FMT ("before: %lu" , zend_memory_usage (TRUE));
488
456
489
- #if PHP_DEBUG
490
- /* -1 is also "true" */
491
- if (* threshold ) {
492
- #endif
457
+ if (* threshold == 0 ) {
458
+ ret = NULL ;
459
+ } else {
493
460
ret = realloc (REAL_PTR (ptr ), REAL_SIZE (new_size ));
494
- #if PHP_DEBUG
495
461
-- * threshold ;
496
- } else if (* threshold == 0 ) {
497
- ret = NULL ;
498
462
}
463
+ #else
464
+ TRACE_ALLOC_ENTER (mysqlnd_realloc_name );
465
+ TRACE_ALLOC_INF_FMT ("ptr=%p new_size=%lu " , new_size , ptr );
466
+ TRACE_ALLOC_INF_FMT ("before: %lu" , zend_memory_usage (TRUE));
467
+ ret = realloc (REAL_PTR (ptr ), REAL_SIZE (new_size ));
499
468
#endif
500
469
501
470
TRACE_ALLOC_INF_FMT ("new_ptr=%p" , (char * )ret );
0 commit comments