summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorivmai <ivmai>2011-03-20 10:08:55 +0100
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:56 +0200
commitc2dddb53a10205f986ae782e5b1e7105f0ea80c5 (patch)
tree311e1519f2ee67241419a1a443694dcd06bff7b4 /tests
parentdc399deadba2c4344d3e9952d1ee2b7bbf24b5e5 (diff)
2011-03-20 Ivan Maidanski <ivmai@mail.ru>
* alloc.c (GC_finish_collection): Remove redundant brackets; adjust code indentation. * blacklst.c (GC_add_to_black_list_normal): Simplify expression (to improve code readability). * blacklst.c (GC_is_black_listed): Join nested "if" (into a single conditional expression); initialize "nblocks" just before the loop beginning. * misc.c (GC_init): Don't compute initial_heap_sz if GC is already initialized. * include/private/gc_priv.h (GC_initialize_offsets): Move the function declaration to misc.c file. * obj_map.c (GC_initialize_offsets): Remove offsets_initialized static variable since the function is called only once. * tests/middle.c: Include "gc.h" instead of <gc.h>; expand all tabs to spaces; adjust code indentation; replace the K&R-style function definition with the ANSI C one. * tests/smash_test.c: Ditto. * tests/middle.c (main): Use setter for GC_all_interior_pointers; adjust printf format specifier (and cast the value passed to).
Diffstat (limited to 'tests')
-rw-r--r--tests/middle.c31
-rw-r--r--tests/smash_test.c24
2 files changed, 27 insertions, 28 deletions
diff --git a/tests/middle.c b/tests/middle.c
index ebb348c..ff0a235 100644
--- a/tests/middle.c
+++ b/tests/middle.c
@@ -2,25 +2,24 @@
* Test at the boundary between small and large objects.
* Inspired by a test case from Zoltan Varga.
*/
-#include <gc.h>
+#include "gc.h"
#include <stdio.h>
-int main ()
+int main (void)
{
- int i;
+ int i;
- GC_all_interior_pointers = 0;
- GC_INIT();
+ GC_set_all_interior_pointers(0);
+ GC_INIT();
- for (i = 0; i < 20000; ++i) {
- GC_malloc_atomic (4096);
- GC_malloc (4096);
- }
- for (i = 0; i < 20000; ++i) {
- GC_malloc_atomic (2048);
- GC_malloc (2048);
- }
- printf("Final heap size is %ld\n", GC_get_heap_size());
- return 0;
+ for (i = 0; i < 20000; ++i) {
+ GC_malloc_atomic (4096);
+ GC_malloc (4096);
+ }
+ for (i = 0; i < 20000; ++i) {
+ GC_malloc_atomic (2048);
+ GC_malloc (2048);
+ }
+ printf("Final heap size is %lu\n", (unsigned long)GC_get_heap_size());
+ return 0;
}
-
diff --git a/tests/smash_test.c b/tests/smash_test.c
index b94af90..86e081b 100644
--- a/tests/smash_test.c
+++ b/tests/smash_test.c
@@ -2,7 +2,8 @@
* Test that overwrite error detection works reasonably.
*/
#define GC_DEBUG
-#include <gc.h>
+#include "gc.h"
+
#include <stdio.h>
#define COUNT 7000
@@ -10,19 +11,18 @@
char * A[COUNT];
-int main ()
+int main(void)
{
- int i;
- char *p;
+ int i;
+ char *p;
- GC_INIT();
+ GC_INIT();
- for (i = 0; i < COUNT; ++i) {
- A[i] = p = GC_MALLOC(SIZE);
+ for (i = 0; i < COUNT; ++i) {
+ A[i] = p = GC_MALLOC(SIZE);
- if (i%3000 == 0) GC_gcollect();
- if (i%5678 == 0) p[SIZE + i/2000] = 42;
- }
- return 0;
+ if (i%3000 == 0) GC_gcollect();
+ if (i%5678 == 0) p[SIZE + i/2000] = 42;
+ }
+ return 0;
}
-