X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=cacao.git;a=blobdiff_plain;f=src%2Fmm%2Fboehm-gc%2Ftests%2Fhuge_test.c;h=5ecc8311b836db04cada25129186202e1c75faf6;hp=248b1d71218a159d351244c03a546c9c0d43b199;hb=c9ee016a64e925938f84fcb85521f82febcc4f63;hpb=c83bff94e40ee0a218a39931af17814d1a42cb5c diff --git a/src/mm/boehm-gc/tests/huge_test.c b/src/mm/boehm-gc/tests/huge_test.c index 248b1d712..5ecc8311b 100644 --- a/src/mm/boehm-gc/tests/huge_test.c +++ b/src/mm/boehm-gc/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; } -