Added API function to retrive current custom heap handlers
authorDmitry Stogov <dmitry@zend.com>
Tue, 14 Oct 2014 10:20:25 +0000 (14:20 +0400)
committerDmitry Stogov <dmitry@zend.com>
Tue, 14 Oct 2014 10:20:25 +0000 (14:20 +0400)
Zend/zend_alloc.c
Zend/zend_alloc.h

index 32d2e5f23463b43586852da25ac4d2697162c5a2..20313fa28c63db842e673d241c8ca3b8dec2d42a 100644 (file)
@@ -2423,6 +2423,30 @@ ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
 #endif
 }
 
+ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap,
+                                          void* (**_malloc)(size_t),
+                                          void  (**_free)(void*),
+                                          void* (**_realloc)(void*, size_t))
+{
+#if ZEND_MM_CUSTOM
+       zend_mm_heap *_heap = (zend_mm_heap*)heap;
+
+       if (heap->use_custom_heap) {
+               *_malloc = _heap->_malloc;
+               *_free = _heap->_free;
+               *_realloc = _heap->_realloc;
+       } else {
+               *_malloc = NULL;
+               *_free = NULL;
+               *_realloc = NULL;
+       }
+#else
+       *_malloc = NULL;
+       *_free = NULL;
+       *_realloc = NULL;
+#endif
+}
+
 ZEND_API zend_mm_storage *zend_mm_get_storage(zend_mm_heap *heap)
 {
 #if ZEND_MM_CUSTOM
index d0226bd04d8f5fcaae3588872281ab58a188b755..c9918955ab647aebfb090c9cedab3cc2f3e1b91c 100644 (file)
@@ -259,6 +259,10 @@ ZEND_API void zend_mm_set_custom_handlers(zend_mm_heap *heap,
                                           void* (*_malloc)(size_t),
                                           void  (*_free)(void*),
                                           void* (*_realloc)(void*, size_t));
+ZEND_API void zend_mm_get_custom_handlers(zend_mm_heap *heap,
+                                          void* (**_malloc)(size_t),
+                                          void  (**_free)(void*),
+                                          void* (**_realloc)(void*, size_t));
 
 typedef struct _zend_mm_storage zend_mm_storage;