source:
CIVL/examples/languageFeatures/forall.cvl
| Last change on this file was d24f3f3, checked in by , 9 months ago | |
|---|---|
|
|
| File size: 387 bytes | |
| Line | |
|---|---|
| 1 | #include <stdlib.h> |
| 2 | |
| 3 | typedef struct M { |
| 4 | int f; |
| 5 | } *B; |
| 6 | |
| 7 | typedef struct S { |
| 8 | B g; |
| 9 | } *A; |
| 10 | |
| 11 | int main() { |
| 12 | int n = 2; |
| 13 | A x[2]; |
| 14 | for (int i = 0; i < n; i++) { |
| 15 | x[i] = (A)malloc(sizeof(struct S)); |
| 16 | x[i]->g = (B)malloc(sizeof(struct M)); |
| 17 | x[i]->g->f = 4; |
| 18 | } |
| 19 | $assert($forall(int i : 0 .. n - 1) x[i]->g->f == 4); |
| 20 | $for(int i: 0 .. n-1) { |
| 21 | free(x[i]->g); |
| 22 | free(x[i]); |
| 23 | } |
| 24 | } |
Note:
See TracBrowser
for help on using the repository browser.
