diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2014-03-10 20:04:58 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2014-03-10 20:34:21 +0400 |
commit | ff6c3d9fb8e7065ffe74cb780b2c1f54868152e2 (patch) | |
tree | 217fff9b7a746308ab36bf399d7e5753be31f03c /tests/test.c | |
parent | 784d789a93ec0ce6ceec5ef860990418f452f087 (diff) | |
download | bdwgc-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 'tests/test.c')
-rw-r--r-- | tests/test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test.c b/tests/test.c index 34c6307b..6f412c8f 100644 --- a/tests/test.c +++ b/tests/test.c @@ -548,6 +548,25 @@ void check_marks_int_list(sexpr x) #endif +void test_generic_malloc_or_special(void *p) { + size_t size; + int kind = GC_get_kind_and_size(p, &size); + void *p2; + + if (size != GC_size(p)) { + GC_printf("GC_get_kind_and_size returned size not matching GC_size\n"); + FAIL; + } + p2 = GC_GENERIC_OR_SPECIAL_MALLOC(10, kind); + CHECK_OUT_OF_MEMORY(p2); + if (GC_get_kind_and_size(p2, NULL) != kind) { + GC_printf("GC_generic_or_special_malloc:" + " unexpected kind of returned object\n"); + FAIL; + } + GC_FREE(p2); +} + /* Try to force a to be strangely aligned */ struct { char dummy; @@ -596,6 +615,7 @@ void *GC_CALLBACK reverse_test_inner(void *data) b = ints(1, 50); c = ints(1, BIG); d = uncollectable_ints(1, 100); + test_generic_malloc_or_special(d); e = uncollectable_ints(1, 1); /* Check that realloc updates object descriptors correctly */ collectable_count++; @@ -606,6 +626,7 @@ void *GC_CALLBACK reverse_test_inner(void *data) f[5] = ints(1,17); collectable_count++; g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr)); + test_generic_malloc_or_special(g); realloc_count++; g = (sexpr *)GC_REALLOC((void *)g, 800 * sizeof(sexpr)); CHECK_OUT_OF_MEMORY(g); @@ -1283,6 +1304,7 @@ void run_one_test(void) GC_FREE(GC_MALLOC(0)); (void)GC_MALLOC_ATOMIC(0); GC_FREE(GC_MALLOC_ATOMIC(0)); + test_generic_malloc_or_special(GC_malloc_atomic(1)); } } # ifdef GC_GCJ_SUPPORT |