Files
bdwgc/tests/realloc_test.c
Ivan Maidanski 0592da8c47 Print relevant message in tests not appropriate for leak detection mode
* cord/tests/cordtest.c (main): If GC_get_find_leak() then print a
message that the test is not designed for leak detection mode (i.e.,
plenty of leaks could be reported).
* tests/disclaim_bench.c (main): Likewise.
* tests/disclaim_test.c (main): Likewise.
* tests/disclaim_weakmap_test.c (main): Likewise.
* tests/initsecondarythread.c (main): Likewise.
* tests/middle.c (main): Likewise.
* tests/realloc_test.c (main): Likewise.
* tests/staticrootstest.c (main): Likewise.
* tests/test_cpp.cc (main): Likewise.
* tests/threadkey_test.c (main): Likewise.
* tests/trace_test.c (main): Likewise.
2018-11-23 01:17:28 +03:00

37 lines
781 B
C

#include <stdio.h>
#include <stdlib.h>
#include "gc.h"
#define COUNT 10000000
int main(void) {
int i;
unsigned long last_heap_size = 0;
GC_INIT();
if (GC_get_find_leak())
printf("This test program is not designed for leak detection mode\n");
for (i = 0; i < COUNT; i++) {
int **p = GC_NEW(int *);
int *q = (int*)GC_MALLOC_ATOMIC(sizeof(int));
if (p == 0 || *p != 0) {
fprintf(stderr, "GC_malloc returned garbage (or NULL)\n");
exit(1);
}
*p = (int*)GC_REALLOC(q, 2 * sizeof(int));
if (i % 10 == 0) {
unsigned long heap_size = (unsigned long)GC_get_heap_size();
if (heap_size != last_heap_size) {
printf("Heap size: %lu\n", heap_size);
last_heap_size = heap_size;
}
}
}
return 0;
}