ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
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 4ed70597 was 46f1d20, checked in by Thierry Delisle <tdelisle@…>, 9 years ago |
|
some changes to checks in gc which are very intrusive
|
-
Property mode
set to
100644
|
|
File size:
919 bytes
|
| Line | |
|---|
| 1 | #include "gc.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <stdio.h>
|
|---|
| 4 |
|
|---|
| 5 | struct List_t
|
|---|
| 6 | {
|
|---|
| 7 | gcpointer(List_t) next;
|
|---|
| 8 | int val;
|
|---|
| 9 | };
|
|---|
| 10 |
|
|---|
| 11 | typedef gcpointer(List_t) LLL;
|
|---|
| 12 |
|
|---|
| 13 | #define MAX (1024 * 1024)
|
|---|
| 14 |
|
|---|
| 15 | LLL buildLLL(int sz)
|
|---|
| 16 | {
|
|---|
| 17 | int i = 0;
|
|---|
| 18 | LLL ll0, lll, llc;
|
|---|
| 19 |
|
|---|
| 20 | gcmalloc( &ll0 );
|
|---|
| 21 | List_t* ll0_ptr = get( &ll0 );
|
|---|
| 22 | ll0_ptr->val = i;
|
|---|
| 23 | lll = ll0;
|
|---|
| 24 |
|
|---|
| 25 | for (i = 1; i < sz; i++)
|
|---|
| 26 | {
|
|---|
| 27 | gcmalloc( &llc );
|
|---|
| 28 | List_t* llc_ptr = get( &llc );
|
|---|
| 29 | llc_ptr->val = i;
|
|---|
| 30 | List_t* lll_ptr = get( &lll );
|
|---|
| 31 | lll_ptr->next = llc;
|
|---|
| 32 |
|
|---|
| 33 | lll = llc;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | return ll0;
|
|---|
| 37 | }
|
|---|
| 38 |
|
|---|
| 39 | void testLLL(LLL lll)
|
|---|
| 40 | {
|
|---|
| 41 | unsigned char *counted;
|
|---|
| 42 |
|
|---|
| 43 | counted = (unsigned char *) calloc(MAX, sizeof(unsigned char));
|
|---|
| 44 | while (lll)
|
|---|
| 45 | {
|
|---|
| 46 | List_t* lll_ptr = get( &lll );
|
|---|
| 47 | counted[lll_ptr->val]++;
|
|---|
| 48 | if (counted[lll_ptr->val] > 1)
|
|---|
| 49 | {
|
|---|
| 50 | fprintf(stderr, "ERROR! Encountered %d twice!\n", lll_ptr->val);
|
|---|
| 51 | exit(1);
|
|---|
| 52 | }
|
|---|
| 53 | lll = lll_ptr->next;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | return;
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | int main(void)
|
|---|
| 60 | {
|
|---|
| 61 | LLL mylll;
|
|---|
| 62 |
|
|---|
| 63 | mylll = buildLLL(MAX);
|
|---|
| 64 |
|
|---|
| 65 | testLLL(mylll);
|
|---|
| 66 |
|
|---|
| 67 | return 0;
|
|---|
| 68 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.