File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -2376,6 +2376,40 @@ ZEND_API int is_zend_mm(void)
2376
2376
#endif
2377
2377
}
2378
2378
2379
+ ZEND_API int is_zend_ptr (const void * ptr )
2380
+ {
2381
+ #if ZEND_MM_CUSTOM
2382
+ if (AG (mm_heap )-> use_custom_heap ) {
2383
+ return 0 ;
2384
+ }
2385
+ #endif
2386
+
2387
+ if (AG (mm_heap )-> main_chunk ) {
2388
+ zend_mm_chunk * chunk = AG (mm_heap )-> main_chunk ;
2389
+
2390
+ do {
2391
+ if (ptr >= (void * )chunk
2392
+ && ptr < (void * )((char * )chunk + ZEND_MM_CHUNK_SIZE )) {
2393
+ return 1 ;
2394
+ }
2395
+ chunk = chunk -> next ;
2396
+ } while (chunk != AG (mm_heap )-> main_chunk );
2397
+ }
2398
+
2399
+ if (AG (mm_heap )-> huge_list ) {
2400
+ zend_mm_huge_list * block = AG (mm_heap )-> huge_list ;
2401
+
2402
+ do {
2403
+ if (ptr >= (void * )block
2404
+ && ptr < (void * )((char * )block + block -> size )) {
2405
+ return 1 ;
2406
+ }
2407
+ block = block -> next ;
2408
+ } while (block != AG (mm_heap )-> huge_list );
2409
+ }
2410
+ return 0 ;
2411
+ }
2412
+
2379
2413
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P )
2380
2414
#undef _emalloc
2381
2415
Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ ZEND_API int zend_set_memory_limit(size_t memory_limit);
224
224
ZEND_API void start_memory_manager (void );
225
225
ZEND_API void shutdown_memory_manager (int silent , int full_shutdown );
226
226
ZEND_API int is_zend_mm (void );
227
+ ZEND_API int is_zend_ptr (const void * ptr );
227
228
228
229
ZEND_API size_t zend_memory_usage (int real_usage );
229
230
ZEND_API size_t zend_memory_peak_usage (int real_usage );
You can’t perform that action at this time.
0 commit comments