Advertisement
Beatgodes

Untitled

May 18th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #define NULL ((void *)0)
  2.  
  3.  
  4. /*@
  5.     requires n >= 0;
  6.     assigns \result \from \nothing;
  7.     ensures \result == \null || \valid(((char*)\result)+(0..n-1));
  8. @*/
  9. void *malloc(int n);
  10.  
  11. /*@
  12.     requires \valid(a);
  13.     requires \valid(b);
  14.     requires \separated(a, b);
  15.     assigns \nothing;
  16.     ensures \result == \null || \valid(\result);
  17.     ensures \separated(a, b);
  18.     ensures \result != \null ==> \separated(a, b, \result); // proved on assumption with HELPER
  19. @*/
  20. int* foo(int *a, int *b){
  21.     int *c = (int*)malloc(sizeof(int));
  22.     if(!c) return NULL;
  23.     //@ assert \separated(a, b);
  24.     //@ assert HELPER: \separated(a, b, c); // cant prove this.
  25.     return c;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement