source: CIVL/examples/mem/mem_tests/mem_contains_malloced.cvl

main
Last change on this file 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: 622 bytes
Line 
1#include<mem.cvh>
2#include<stdlib.h>
3
4$input int N;
5$assume(N > 10);
6int *a;
7int **b;
8
9int main() {
10 a = (int *)malloc(sizeof(int) * N);
11 b = (int **)malloc(sizeof(int*) * 10);
12 for (int i = 0; i < 5; i++)
13 b[i] = (int *)malloc(sizeof(int) * 5);
14
15 $assert($mem_contains(a + (0 .. N-1), a + (0 .. N-2)));
16 $assert($mem_contains(a + (0 .. N-1), a + 1));
17 $assert(!$mem_contains(a + (0 .. N-2), a + (0 .. N-1)));
18 free(a);
19
20 $assert($mem_contains(b[0] + (0 .. 4), b[0]));
21 $assert($mem_contains(b + (0 .. 4), b));
22 $assert(!$mem_contains(b, b[0]));
23
24 for (int i = 0; i < 5; i++)
25 free(b[i]);
26 free(b);
27}
Note: See TracBrowser for help on using the repository browser.