mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Provide is_zend_ptr() function to check if a pointer lays in Zend MM heap.
This commit is contained in:
parent
05f3706588
commit
4d0a2f68a9
2 changed files with 35 additions and 0 deletions
|
@ -2376,6 +2376,40 @@ ZEND_API int is_zend_mm(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ZEND_API int is_zend_ptr(const void *ptr)
|
||||||
|
{
|
||||||
|
#if ZEND_MM_CUSTOM
|
||||||
|
if (AG(mm_heap)->use_custom_heap) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (AG(mm_heap)->main_chunk) {
|
||||||
|
zend_mm_chunk *chunk = AG(mm_heap)->main_chunk;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (ptr >= (void*)chunk
|
||||||
|
&& ptr < (void*)((char*)chunk + ZEND_MM_CHUNK_SIZE)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
chunk = chunk->next;
|
||||||
|
} while (chunk != AG(mm_heap)->main_chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AG(mm_heap)->huge_list) {
|
||||||
|
zend_mm_huge_list *block = AG(mm_heap)->huge_list;
|
||||||
|
|
||||||
|
do {
|
||||||
|
if (ptr >= (void*)block
|
||||||
|
&& ptr < (void*)((char*)block + block->size)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
block = block->next;
|
||||||
|
} while (block != AG(mm_heap)->huge_list);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
|
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
|
||||||
#undef _emalloc
|
#undef _emalloc
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,7 @@ ZEND_API int zend_set_memory_limit(size_t memory_limit);
|
||||||
ZEND_API void start_memory_manager(void);
|
ZEND_API void start_memory_manager(void);
|
||||||
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown);
|
ZEND_API void shutdown_memory_manager(int silent, int full_shutdown);
|
||||||
ZEND_API int is_zend_mm(void);
|
ZEND_API int is_zend_mm(void);
|
||||||
|
ZEND_API int is_zend_ptr(const void *ptr);
|
||||||
|
|
||||||
ZEND_API size_t zend_memory_usage(int real_usage);
|
ZEND_API size_t zend_memory_usage(int real_usage);
|
||||||
ZEND_API size_t zend_memory_peak_usage(int real_usage);
|
ZEND_API size_t zend_memory_peak_usage(int real_usage);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue