mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
zend_alloc: Fix compile with ZEND_MM_STAT=0
Closes GH-18811.
This commit is contained in:
1
NEWS
1
NEWS
@@ -6,6 +6,7 @@ PHP NEWS
|
||||
. Fixed GH-18695 (zend_ast_export() - float number is not preserved).
|
||||
(Oleg Efimov)
|
||||
. Do not delete main chunk in zend_gc. (danog, Arnaud)
|
||||
. Fix compile issues with zend_alloc and some non-default options. (nielsdos)
|
||||
|
||||
- Curl:
|
||||
. Fix memory leak when setting a list via curl_setopt fails. (nielsdos)
|
||||
|
||||
@@ -2274,7 +2274,9 @@ void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent)
|
||||
/* Make sure the heap free below does not use tracked_free(). */
|
||||
heap->custom_heap.std._free = free;
|
||||
}
|
||||
#if ZEND_MM_STAT
|
||||
heap->size = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (full) {
|
||||
@@ -2820,6 +2822,7 @@ static zend_always_inline zval *tracked_get_size_zv(zend_mm_heap *heap, void *pt
|
||||
}
|
||||
|
||||
static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t add_size) {
|
||||
#if ZEND_MM_STAT
|
||||
if (add_size > heap->limit - heap->size && !heap->overflow) {
|
||||
#if ZEND_DEBUG
|
||||
zend_mm_safe_error(heap,
|
||||
@@ -2831,6 +2834,7 @@ static zend_always_inline void tracked_check_limit(zend_mm_heap *heap, size_t ad
|
||||
heap->limit, add_size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *tracked_malloc(size_t size)
|
||||
@@ -2844,7 +2848,9 @@ static void *tracked_malloc(size_t size)
|
||||
}
|
||||
|
||||
tracked_add(heap, ptr, size);
|
||||
#if ZEND_MM_STAT
|
||||
heap->size += size;
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
@@ -2855,7 +2861,9 @@ static void tracked_free(void *ptr) {
|
||||
|
||||
zend_mm_heap *heap = AG(mm_heap);
|
||||
zval *size_zv = tracked_get_size_zv(heap, ptr);
|
||||
#if ZEND_MM_STAT
|
||||
heap->size -= Z_LVAL_P(size_zv);
|
||||
#endif
|
||||
zend_hash_del_bucket(heap->tracked_allocs, (Bucket *) size_zv);
|
||||
free(ptr);
|
||||
}
|
||||
@@ -2880,7 +2888,9 @@ static void *tracked_realloc(void *ptr, size_t new_size) {
|
||||
|
||||
ptr = __zend_realloc(ptr, new_size);
|
||||
tracked_add(heap, ptr, new_size);
|
||||
#if ZEND_MM_STAT
|
||||
heap->size += new_size - old_size;
|
||||
#endif
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user