Skip to content

Commit d2daa19

Browse files
committed
Added API function to retrive current custom heap handlers
1 parent afdaeda commit d2daa19

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Zend/zend_alloc.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,6 +2423,30 @@ ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
24232423
#endif
24242424
}
24252425

2426+
ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap,
2427+
void* (**_malloc)(size_t),
2428+
void (**_free)(void*),
2429+
void* (**_realloc)(void*, size_t))
2430+
{
2431+
#if ZEND_MM_CUSTOM
2432+
zend_mm_heap *_heap = (zend_mm_heap*)heap;
2433+
2434+
if (heap->use_custom_heap) {
2435+
*_malloc = _heap->_malloc;
2436+
*_free = _heap->_free;
2437+
*_realloc = _heap->_realloc;
2438+
} else {
2439+
*_malloc = NULL;
2440+
*_free = NULL;
2441+
*_realloc = NULL;
2442+
}
2443+
#else
2444+
*_malloc = NULL;
2445+
*_free = NULL;
2446+
*_realloc = NULL;
2447+
#endif
2448+
}
2449+
24262450
ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap)
24272451
{
24282452
#if ZEND_MM_CUSTOM

Zend/zend_alloc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
259259
void* (*_malloc)(size_t),
260260
void (*_free)(void*),
261261
void* (*_realloc)(void*, size_t));
262+
ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap,
263+
void* (**_malloc)(size_t),
264+
void (**_free)(void*),
265+
void* (**_realloc)(void*, size_t));
262266

263267
typedef struct _zend_mm_storage zend_mm_storage;
264268

0 commit comments

Comments
 (0)