From beb05b8db4cb8c1cee978a59b0d7235d7f4f8be4 Mon Sep 17 00:00:00 2001 From: ivmai Date: Thu, 1 Oct 2009 19:23:14 +0000 Subject: [PATCH] 2009-10-01 Ivan Maidanski * tests/huge_test.c: Define GC_IGNORE_WARN (if not defined) to suppress misleading GC "Out of Memory!" warning printed on every GC_MALLOC(LONG_MAX) call. * tests/huge_test.c: Include "gc.h" instead of . * tests/huge_test.c (main): Replace K&R-style function definition with the ANSI C one. * tests/huge_test.c: Expand all tabs to spaces. --- ChangeLog | 10 ++++++++++ tests/huge_test.c | 49 +++++++++++++++++++++++++++-------------------- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46f2c88f..a04ceb10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-10-01 Ivan Maidanski + + * tests/huge_test.c: Define GC_IGNORE_WARN (if not defined) to + suppress misleading GC "Out of Memory!" warning printed on every + GC_MALLOC(LONG_MAX) call. + * tests/huge_test.c: Include "gc.h" instead of . + * tests/huge_test.c (main): Replace K&R-style function definition + with the ANSI C one. + * tests/huge_test.c: Expand all tabs to spaces. + 2009-10-01 Ivan Maidanski * dyn_load.c (GC_register_dynamic_libraries): Always use diff --git a/tests/huge_test.c b/tests/huge_test.c index 248b1d71..5ecc8311 100644 --- a/tests/huge_test.c +++ b/tests/huge_test.c @@ -1,7 +1,16 @@ + #include #include #include -#include + +#ifndef GC_IGNORE_WARN + /* Ignore misleading "Out of Memory!" warning (which is printed on */ + /* every GC_MALLOC(LONG_MAX) call) by defining this macro before */ + /* "gc.h" inclusion. */ +# define GC_IGNORE_WARN +#endif + +#include "gc.h" /* * Check that very large allocation requests fail. "Success" would usually @@ -10,36 +19,34 @@ * expected manner. */ - -main() +int main(void) { GC_INIT(); GC_set_max_heap_size(100*1024*1024); - /* Otherwise heap expansion aborts when deallocating large block. */ + /* Otherwise heap expansion aborts when deallocating large block. */ /* That's OK. We test this corner case mostly to make sure that */ - /* it fails predictably. */ + /* it fails predictably. */ GC_expand_hp(1024*1024*5); if (sizeof(long) == sizeof(void *)) { void *r = GC_MALLOC(LONG_MAX-1024); - if (0 != r) { - fprintf(stderr, - "Size LONG_MAX-1024 allocation unexpectedly succeeded\n"); - exit(1); - } + if (0 != r) { + fprintf(stderr, + "Size LONG_MAX-1024 allocation unexpectedly succeeded\n"); + exit(1); + } r = GC_MALLOC(LONG_MAX); - if (0 != r) { - fprintf(stderr, - "Size LONG_MAX allocation unexpectedly succeeded\n"); - exit(1); - } + if (0 != r) { + fprintf(stderr, + "Size LONG_MAX allocation unexpectedly succeeded\n"); + exit(1); + } r = GC_MALLOC((size_t)LONG_MAX + 1024); - if (0 != r) { - fprintf(stderr, - "Size LONG_MAX+1024 allocation unexpectedly succeeded\n"); - exit(1); - } + if (0 != r) { + fprintf(stderr, + "Size LONG_MAX+1024 allocation unexpectedly succeeded\n"); + exit(1); + } } return 0; } - -- 2.40.0