Ignore:
Timestamp:
Sep 9, 2016, 11:50:04 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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
Message:

some changes to checks in gc which are very intrusive

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/gc_no_raii/test/badlll.c

    r850fda6 r46f1d20  
    11#include "gc.h"
     2
     3#include <stdio.h>
    24
    35struct List_t
     
    79};
    810
    9 void ?{}(List_t* this);
    10 List_t* ?=?(List_t* this, List_t* rhs);
    11 
    1211typedef gcpointer(List_t) LLL;
    1312
    1413#define MAX (1024 * 1024)
    1514
    16 // LLL buildLLL(int sz)
    17 void bla()
     15LLL buildLLL(int sz)
    1816{
    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;
    3537}
    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
     39void 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}
    5558
    5659int main(void)
     
    5861        LLL mylll;
    5962
    60         // mylll = buildLLL(MAX);
    61         //
    62         // testLLL(mylll);
     63        mylll = buildLLL(MAX);
     64
     65        testLLL(mylll);
    6366
    6467        return 0;
Note: See TracChangeset for help on using the changeset viewer.