Changeset 46f1d20 for src/examples/gc_no_raii/test/badlll.c
- Timestamp:
- Sep 9, 2016, 11:50:04 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ddcfb88
- Parents:
- 850fda6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/test/badlll.c
r850fda6 r46f1d20 1 1 #include "gc.h" 2 3 #include <stdio.h> 2 4 3 5 struct List_t … … 7 9 }; 8 10 9 void ?{}(List_t* this);10 List_t* ?=?(List_t* this, List_t* rhs);11 12 11 typedef gcpointer(List_t) LLL; 13 12 14 13 #define MAX (1024 * 1024) 15 14 16 // LLL buildLLL(int sz) 17 void bla() 15 LLL buildLLL(int sz) 18 16 { 19 int i; 20 // LLL ll0;//, lll, llc; 21 // 22 // ll0 = gcmalloc(); 23 // ll0->val = 0; 24 // lll = ll0; 25 // 26 // for (i = 1; i < sz; i++) 27 // { 28 // llc = gcmalloc(); 29 // llc->val = i; 30 // lll->next = llc; 31 // lll = llc; 32 // } 33 // 34 // return ll0; 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; 35 37 } 36 // 37 // void testLLL(LLL lll) 38 // { 39 // unsigned char *counted; 40 // 41 // counted = (unsigned char *) calloc(MAX, sizeof(unsigned char)); 42 // while (lll) 43 // { 44 // counted[lll->val]++; 45 // if (counted[lll->val] > 1) 46 // { 47 // fprintf(stderr, "ERROR! Encountered %d twice!\n", lll->val); 48 // exit(1); 49 // } 50 // lll = lll->next; 51 // } 52 // 53 // return; 54 // } 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 } 55 58 56 59 int main(void) … … 58 61 LLL mylll; 59 62 60 //mylll = buildLLL(MAX);61 // 62 //testLLL(mylll);63 mylll = buildLLL(MAX); 64 65 testLLL(mylll); 63 66 64 67 return 0;
Note: See TracChangeset
for help on using the changeset viewer.