summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-12-29 16:12:37 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-12-29 16:12:37 +0400
commitdcf6f521380c9e686956e8df7afb1e04d088091b (patch)
tree40638531915620d23c3bfe3141c12ada575b1021 /misc.c
parent089667c19cde23eb5988778411ff28e186465d16 (diff)
downloadbdwgc-dcf6f521380c9e686956e8df7afb1e04d088091b.tar.gz
Add GC_is_heap_ptr() to GC API
* include/gc.h (GC_is_heap_ptr): New API function declaration. * misc.c (GC_is_heap_ptr): New function. * tests/test.c (run_one_test): Add GC_is_heap_ptr tests.
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index 18cc44d5..63262e1e 100644
--- a/misc.c
+++ b/misc.c
@@ -391,6 +391,15 @@ GC_API void * GC_CALL GC_base(void * p)
return((void *)r);
}
+/* Return TRUE if and only if p points to somewhere in GC heap. */
+GC_API int GC_CALL GC_is_heap_ptr(const void *p)
+{
+ bottom_index *bi;
+
+ GC_ASSERT(GC_is_initialized);
+ GET_BI(p, bi);
+ return HDR_FROM_BI(bi, p) != 0;
+}
/* Return the size of an object, given a pointer to its base. */
/* (For small objects this also happens to work from interior pointers, */