summaryrefslogtreecommitdiff
path: root/mallocx.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2014-03-10 20:04:58 +0400
committerIvan Maidanski <ivmai@mail.ru>2014-03-10 20:34:21 +0400
commitff6c3d9fb8e7065ffe74cb780b2c1f54868152e2 (patch)
tree217fff9b7a746308ab36bf399d7e5753be31f03c /mallocx.c
parent784d789a93ec0ce6ceec5ef860990418f452f087 (diff)
downloadbdwgc-ff6c3d9fb8e7065ffe74cb780b2c1f54868152e2.tar.gz
Define public GC_GENERIC_OR_SPECIAL_MALLOC and GC_get_kind_and_size
* dbg_mlc.c (GC_debug_generic_malloc, GC_debug_generic_or_special_malloc): New function. * mallocx.c (GC_get_kind_and_size): Likewise. * tests/test.c (test_generic_malloc_or_special): Likewise. * include/gc_mark.h (GC_generic_or_special_malloc, GC_debug_generic_or_special_malloc, GC_get_kind_and_size): New API prototype. * include/gc_mark.h (GC_GENERIC_OR_SPECIAL_MALLOC): New public macro. * mallocx.c (GC_generic_or_special_malloc): Turn into API function. * tests/test.c (reverse_test_inner, run_one_test): Invoke test_generic_malloc_or_special (to test GC_GENERIC_OR_SPECIAL_MALLOC and GC_get_kind_and_size).
Diffstat (limited to 'mallocx.c')
-rw-r--r--mallocx.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/mallocx.c b/mallocx.c
index de9fd931..75ee0e28 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -46,8 +46,17 @@ void ** const GC_uobjfreelist_ptr = GC_uobjfreelist;
void ** const GC_auobjfreelist_ptr = GC_auobjfreelist;
# endif
+GC_API int GC_CALL GC_get_kind_and_size(const void * p, size_t * psize)
+{
+ hdr * hhdr = HDR(p);
+
+ if (psize != NULL) {
+ *psize = hhdr -> hb_sz;
+ }
+ return hhdr -> hb_obj_kind;
+}
-STATIC void * GC_generic_or_special_malloc(size_t lb, int knd)
+GC_API void * GC_CALL GC_generic_or_special_malloc(size_t lb, int knd)
{
switch(knd) {
# ifdef STUBBORN_ALLOC