diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2011-12-29 16:12:37 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-12-29 16:12:37 +0400 |
commit | dcf6f521380c9e686956e8df7afb1e04d088091b (patch) | |
tree | 40638531915620d23c3bfe3141c12ada575b1021 /misc.c | |
parent | 089667c19cde23eb5988778411ff28e186465d16 (diff) | |
download | bdwgc-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.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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, */ |