source: CIVL/examples/contracts/contractsSeq/pointers.c@ bb03188

main test-branch
Last change on this file since bb03188 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: 374 bytes
Line 
1#include <stdlib.h>
2/*@ requires \valid(x);
3 @ ensures \result == *x + 1;
4 @
5*/
6int add(int * x)
7{
8 return *x + 1;
9}
10
11/*@ requires \valid(x);
12 @ requires *x >= 0;
13 @ ensures *x == \result - 1;
14 @*/
15int incr(int * x)
16{
17 int * y;
18 int ret;
19
20 y = (int*)malloc(sizeof(int));
21 ret = add(x);
22 free(y);
23 return ret;
24}
25
26int main() {
27 incr((void *)-1);
28 return 0;
29}
Note: See TracBrowser for help on using the repository browser.