/* * * This example is to show the structure of a heap in CIVL. * use the -showSavedStates to see how heap is represented. * */ #include typedef struct Node{ int id; struct Node *next; } Node; int *ip; double *dp; Node *q; _Bool start = $false; _Bool finish = $false; int count = 0; void foo(){ $when(start); q = (Node *) $malloc($root, sizeof(Node)*2); q[0].id = 1; q[0].next = q+1; q[1].id = 2; q[1].next = NULL; count++; if(count == 2){ finish=$true; } $when(finish); $free(ip); $free(dp); } void goo() { $when(start); ip = (int *) $malloc($root, sizeof(int)*3); (*ip) = 1; dp = (double *) $malloc($root, sizeof(double)*4); dp[0] = 1.0; (*(ip+1)) = 2; dp[1] = 2.0; (*(ip+2)) = 3; dp[2] = 3.0; dp[3] = 4.0; count++; if(count == 2){ finish=$true; } $when(finish); $free(q); } void main() { $proc fp, gp; fp = $spawn foo(); gp = $spawn goo(); start = $true; $wait fp; $wait gp; }