source: src/examples/gc_no_raii/test/badlll.c@ 00b7cd3

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 00b7cd3 was 85951a6, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

fixed copy paste error in badlll

  • Property mode set to 100644
File size: 735 bytes
Line 
1#include "gc.h"
2
3struct List_t
4{
5 gcpointer(List_t) next;
6 int val;
7};
8
9typedef gcpointer(List_t) LLL;
10
11#define MAX (1024 * 1024)
12
13LLL buildLLL(int sz)
14{
15 int i;
16 LLL ll0, lll, llc;
17
18 ll0 = gcmalloc();
19 ll0->val = 0;
20 lll = ll0;
21
22 for (i = 1; i < sz; i++)
23 {
24 llc = gcmalloc();
25 llc->val = i;
26 lll->next = llc;
27 lll = llc;
28 }
29
30 return ll0;
31}
32
33void testLLL(LLL lll)
34{
35 unsigned char *counted;
36
37 counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
38 while (lll)
39 {
40 counted[lll->val]++;
41 if (counted[lll->val] > 1)
42 {
43 fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val);
44 exit(1);
45 }
46 lll = lll->next;
47 }
48
49 return;
50}
51
52int main(void)
53{
54 LLL mylll;
55
56 mylll = buildLLL(MAX);
57
58 testLLL(mylll);
59
60 return 0;
61}
Note: See TracBrowser for help on using the repository browser.