summaryrefslogtreecommitdiff
path: root/boehm-gc/tests/staticrootstest.c
blob: 68ff9eaea1e31359075a422a83a4e599879f9436 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>

#ifndef GC_DEBUG
# define GC_DEBUG
#endif

#include "gc.h"
#include "gc_backptr.h"

struct treenode {
    struct treenode *x;
    struct treenode *y;
} * root[10];

static char *staticroot = 0;

extern struct treenode * libsrl_mktree(int i);
extern void * libsrl_init(void);
extern void * libsrl_collect (void);

int main(void)
{
  int i;
  staticroot = libsrl_init();
  for (i = 0; i < sizeof(struct treenode); ++i) {
    staticroot[i] = 0x42;
  }
  libsrl_collect();
  for (i = 0; i < 10; ++i) {
    root[i] = libsrl_mktree(12);
    libsrl_collect();
  }
  for (i = 0; i < sizeof(struct treenode); ++i) {
    if (staticroot[i] != 0x42)
      return -1;
  }
  for (i = 0; i < 10; ++i) {
    root[i] = libsrl_mktree(12);
    libsrl_collect();
  }
  for (i = 0; i < sizeof(struct treenode); ++i) {
    if (staticroot[i] != 0x42)
      return -1;
  }
  return 0;
}