about summary refs log tree commit diff
path: root/Src/mem.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/mem.c')
-rw-r--r--Src/mem.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Src/mem.c b/Src/mem.c
index 499f7d7e4..bcdd1efe9 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -329,6 +329,21 @@ mmap_heap_alloc(size_t *n)
 }
 #endif
 
+/* check whether a pointer is within a memory pool */
+
+/**/
+mod_export void *
+zheapptr(void *p)
+{
+    Heap h;
+    queue_signals();
+    for (h = heaps; h; h = h->next)
+	if ((char *)p >= arena(h) &&
+	    (char *)p + H_ISIZE < arena(h) + ARENA_SIZEOF(h))
+	    break;
+    unqueue_signals();
+    return (h ? p : 0);
+}
 
 /* allocate memory from the current memory pool */