@@ -2409,7 +2409,9 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
2409
2409
/* Make sure the heap free below does not use tracked_free(). */
2410
2410
heap -> custom_heap ._free = __zend_free ;
2411
2411
}
2412
+ #if ZEND_MM_STAT
2412
2413
heap -> size = 0 ;
2414
+ #endif
2413
2415
}
2414
2416
2415
2417
void (* shutdown )(bool , bool ) = heap -> custom_heap ._shutdown ;
@@ -2947,6 +2949,7 @@ static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *pt
2947
2949
}
2948
2950
2949
2951
static zend_always_inline void tracked_check_limit (zend_mm_heap * heap , size_t add_size ) {
2952
+ #if ZEND_MM_STAT
2950
2953
if (add_size > heap -> limit - heap -> size && !heap -> overflow ) {
2951
2954
#if ZEND_DEBUG
2952
2955
zend_mm_safe_error (heap ,
@@ -2958,6 +2961,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
2958
2961
heap -> limit , add_size );
2959
2962
#endif
2960
2963
}
2964
+ #endif
2961
2965
}
2962
2966
2963
2967
static void * tracked_malloc (size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC )
@@ -2971,7 +2975,9 @@ static void *tracked_malloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC
2971
2975
}
2972
2976
2973
2977
tracked_add (heap , ptr , size );
2978
+ #if ZEND_MM_STAT
2974
2979
heap -> size += size ;
2980
+ #endif
2975
2981
return ptr ;
2976
2982
}
2977
2983
@@ -2982,7 +2988,9 @@ static void tracked_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
2982
2988
2983
2989
zend_mm_heap * heap = AG (mm_heap );
2984
2990
zval * size_zv = tracked_get_size_zv (heap , ptr );
2991
+ #if ZEND_MM_STAT
2985
2992
heap -> size -= Z_LVAL_P (size_zv );
2993
+ #endif
2986
2994
zend_hash_del_bucket (heap -> tracked_allocs , (Bucket * ) size_zv );
2987
2995
free (ptr );
2988
2996
}
@@ -3007,7 +3015,9 @@ static void *tracked_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_F
3007
3015
3008
3016
ptr = __zend_realloc (ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
3009
3017
tracked_add (heap , ptr , new_size );
3018
+ #if ZEND_MM_STAT
3010
3019
heap -> size += new_size - old_size ;
3020
+ #endif
3011
3021
return ptr ;
3012
3022
}
3013
3023
0 commit comments