source: CIVL/examples/verifyThis/treeBuffer/driver_heap_bound.cvl@ beab7f2

main test-branch
Last change on this file since beab7f2 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include "treebuffer.h"
2#include <stdlib.h>
3
4// bounded number of new nodes that will be added
5$input int N;
6$assume(0 < N && N <= 5);
7$input int HISTORY_SIZE;
8$assume(0 < HISTORY_SIZE && HISTORY_SIZE < N);
9$input int Data[N];
10
11$scope root = $here;
12
13int main() {
14 Tree * tree = empty(HISTORY_SIZE);
15 Tree * forest[N + 1]; // N new tree + the empty tree
16 int num_trees = 0;
17 size_t max_bounds = 0;
18
19 $elaborate(N);
20 forest[num_trees++] = tree;
21 while (num_trees <= N) {
22 int pick = $choose_int(num_trees);
23
24 tree = forest[pick];
25 $elaborate(HISTORY_SIZE);
26 $atomic{
27 Tree * new_tree = add(tree, Data[num_trees-1]);
28
29 forest[num_trees++] = new_tree;
30 tree = new_tree;
31 }
32 // the heap size is bounded within the HISTORY_SIZE if all cached
33 // historical trees are deleted:
34 $choose{
35 $when($true) {
36 for (int i = 0; i < num_trees-1; i++)
37 delete(forest[i]);
38 check_heap_inbound($heap_size(root), HISTORY_SIZE, tree, &max_bounds);
39 delete(tree);
40 return 0;
41 }
42 $when($true) continue;
43 }
44 }
45 for (int i = 0; i < num_trees; i++)
46 delete(forest[i]);
47 return 0;
48}
Note: See TracBrowser for help on using the repository browser.