@@ -2274,7 +2274,9 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
2274
2274
/* Make sure the heap free below does not use tracked_free(). */
2275
2275
heap -> custom_heap .std ._free = free ;
2276
2276
}
2277
+ #if ZEND_MM_STAT
2277
2278
heap -> size = 0 ;
2279
+ #endif
2278
2280
}
2279
2281
2280
2282
if (full ) {
@@ -2820,6 +2822,7 @@ static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *pt
2820
2822
}
2821
2823
2822
2824
static zend_always_inline void tracked_check_limit (zend_mm_heap * heap , size_t add_size ) {
2825
+ #if ZEND_MM_STAT
2823
2826
if (add_size > heap -> limit - heap -> size && !heap -> overflow ) {
2824
2827
#if ZEND_DEBUG
2825
2828
zend_mm_safe_error (heap ,
@@ -2831,6 +2834,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
2831
2834
heap -> limit , add_size );
2832
2835
#endif
2833
2836
}
2837
+ #endif
2834
2838
}
2835
2839
2836
2840
static void * tracked_malloc (size_t size )
@@ -2844,7 +2848,9 @@ static void *tracked_malloc(size_t size)
2844
2848
}
2845
2849
2846
2850
tracked_add (heap , ptr , size );
2851
+ #if ZEND_MM_STAT
2847
2852
heap -> size += size ;
2853
+ #endif
2848
2854
return ptr ;
2849
2855
}
2850
2856
@@ -2855,7 +2861,9 @@ static void tracked_free(void *ptr) {
2855
2861
2856
2862
zend_mm_heap * heap = AG (mm_heap );
2857
2863
zval * size_zv = tracked_get_size_zv (heap , ptr );
2864
+ #if ZEND_MM_STAT
2858
2865
heap -> size -= Z_LVAL_P (size_zv );
2866
+ #endif
2859
2867
zend_hash_del_bucket (heap -> tracked_allocs , (Bucket * ) size_zv );
2860
2868
free (ptr );
2861
2869
}
@@ -2880,7 +2888,9 @@ static void *tracked_realloc(void *ptr, size_t new_size) {
2880
2888
2881
2889
ptr = __zend_realloc (ptr , new_size );
2882
2890
tracked_add (heap , ptr , new_size );
2891
+ #if ZEND_MM_STAT
2883
2892
heap -> size += new_size - old_size ;
2893
+ #endif
2884
2894
return ptr ;
2885
2895
}
2886
2896
0 commit comments