@@ -2409,7 +2409,9 @@ ZEND_API void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
24092409 /* Make sure the heap free below does not use tracked_free(). */
24102410 heap -> custom_heap ._free = __zend_free ;
24112411 }
2412+ #if ZEND_MM_STAT
24122413 heap -> size = 0 ;
2414+ #endif
24132415 }
24142416
24152417 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
29472949}
29482950
29492951static zend_always_inline void tracked_check_limit (zend_mm_heap * heap , size_t add_size ) {
2952+ #if ZEND_MM_STAT
29502953 if (add_size > heap -> limit - heap -> size && !heap -> overflow ) {
29512954#if ZEND_DEBUG
29522955 zend_mm_safe_error (heap ,
@@ -2958,6 +2961,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
29582961 heap -> limit , add_size );
29592962#endif
29602963 }
2964+ #endif
29612965}
29622966
29632967static 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
29712975 }
29722976
29732977 tracked_add (heap , ptr , size );
2978+ #if ZEND_MM_STAT
29742979 heap -> size += size ;
2980+ #endif
29752981 return ptr ;
29762982}
29772983
@@ -2982,7 +2988,9 @@ static void tracked_free(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) {
29822988
29832989 zend_mm_heap * heap = AG (mm_heap );
29842990 zval * size_zv = tracked_get_size_zv (heap , ptr );
2991+ #if ZEND_MM_STAT
29852992 heap -> size -= Z_LVAL_P (size_zv );
2993+ #endif
29862994 zend_hash_del_bucket (heap -> tracked_allocs , (Bucket * ) size_zv );
29872995 free (ptr );
29882996}
@@ -3007,7 +3015,9 @@ static void *tracked_realloc(void *ptr, size_t new_size ZEND_FILE_LINE_DC ZEND_F
30073015
30083016 ptr = __zend_realloc (ptr , new_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC );
30093017 tracked_add (heap , ptr , new_size );
3018+ #if ZEND_MM_STAT
30103019 heap -> size += new_size - old_size ;
3020+ #endif
30113021 return ptr ;
30123022}
30133023
0 commit comments