@@ -2430,7 +2430,9 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
2430
2430
/* Make sure the heap free below does not use tracked_free(). */
2431
2431
heap -> custom_heap ._free = __zend_free ;
2432
2432
}
2433
+ #if ZEND_MM_STAT
2433
2434
heap -> size = 0 ;
2435
+ #endif
2434
2436
}
2435
2437
2436
2438
void (* shutdown )(bool , bool ) = heap -> custom_heap ._shutdown ;
@@ -2969,6 +2971,7 @@ static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *pt
2969
2971
}
2970
2972
2971
2973
static zend_always_inline void tracked_check_limit (zend_mm_heap * heap , size_t add_size ) {
2974
+ #if ZEND_MM_STAT
2972
2975
if (add_size > heap -> limit - heap -> size && !heap -> overflow ) {
2973
2976
#if ZEND_DEBUG
2974
2977
zend_mm_safe_error (heap ,
@@ -2980,6 +2983,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
2980
2983
heap -> limit , add_size );
2981
2984
#endif
2982
2985
}
2986
+ #endif
2983
2987
}
2984
2988
2985
2989
static void * tracked_malloc (size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
@@ -2993,7 +2997,9 @@ static void *tracked_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
2993
2997
}
2994
2998
2995
2999
tracked_add (heap , ptr , size );
3000
+ #if ZEND_MM_STAT
2996
3001
heap -> size += size ;
3002
+ #endif
2997
3003
return ptr ;
2998
3004
}
2999
3005
@@ -3004,7 +3010,9 @@ static void tracked_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
3004
3010
3005
3011
zend_mm_heap * heap = AG (mm_heap );
3006
3012
zval * size_zv = tracked_get_size_zv (heap , ptr );
3013
+ #if ZEND_MM_STAT
3007
3014
heap -> size -= Z_LVAL_P (size_zv );
3015
+ #endif
3008
3016
zend_hash_del_bucket (heap -> tracked_allocs , (Bucket * ) size_zv );
3009
3017
free (ptr );
3010
3018
}
@@ -3029,7 +3037,9 @@ static void *tracked_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_F
3029
3037
3030
3038
ptr = __zend_realloc (ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
3031
3039
tracked_add (heap , ptr , new_size );
3040
+ #if ZEND_MM_STAT
3032
3041
heap -> size += new_size - old_size ;
3042
+ #endif
3033
3043
return ptr ;
3034
3044
}
3035
3045
0 commit comments