Changeset 1eba452 for src/examples/gc_no_raii/test/badlll.c
- Timestamp:
- Sep 15, 2016, 10:29:43 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:
- fc4a0fa, fd782b2
- Parents:
- 96a10cd (diff), 50c5cf3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/test/badlll.c
r96a10cd r1eba452 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 #define MAX (1024 * 1 024)13 #define MAX (1024 * 1) 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; 19 20 gcmalloc( &ll0 ); 21 List_t* ll0_ptr = get( &ll0 ); 22 ll0_ptr->val = i; 23 LLL lll = ll0; 24 25 for (i = 1; i < sz; i++) 26 { 27 LLL llc; 28 gcmalloc( &llc ); 29 List_t* llc_ptr = get( &llc ); 30 llc_ptr->val = i; 31 List_t* lll_ptr = get( &lll ); 32 lll_ptr->next = llc; 33 34 lll = llc; 35 } 36 37 check(is_valid( &ll0.internal )); 38 39 return ll0; 35 40 } 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 // } 41 42 void testLLL(LLL lll) 43 { 44 unsigned char *counted; 45 46 counted = (unsigned char *) calloc(MAX, sizeof(unsigned char)); 47 while (lll) 48 { 49 List_t* lll_ptr = get( &lll ); 50 counted[lll_ptr->val]++; 51 if (counted[lll_ptr->val] > 1) 52 { 53 fprintf(stderr, "ERROR! Encountered %d twice!\n", lll_ptr->val); 54 exit(1); 55 } 56 lll = lll_ptr->next; 57 } 58 59 return; 60 } 55 61 56 62 int main(void) … … 58 64 LLL mylll; 59 65 60 //mylll = buildLLL(MAX);61 // 62 //testLLL(mylll);66 mylll = buildLLL(MAX); 67 68 testLLL(mylll); 63 69 64 70 return 0;
Note: See TracChangeset
for help on using the changeset viewer.