source:
CIVL/examples/library/pointer/symbolicPointerRealloc.cvl@
4dec5e2
| Last change on this file since 4dec5e2 was 58207ec, checked in by , 10 years ago | |
|---|---|
|
|
| File size: 316 bytes | |
| Rev | Line | |
|---|---|---|
| [58207ec] | 1 | #include <pointer.cvh> |
| 2 | #include <stdlib.h> | |
| 3 | ||
| 4 | /* An example shows how $pointer_realloc works. */ | |
| 5 | $input int N; | |
| 6 | $input int M; | |
| 7 | $assume(N > 4 && M > N + 2); | |
| 8 | int main() { | |
| 9 | int * p = (int *)malloc(sizeof(int) * N); | |
| 10 | int a = p[1]; | |
| 11 | ||
| 12 | $pointer_realloc(p, sizeof(int) * M); | |
| 13 | ||
| 14 | $assert(p[1] == a); | |
| 15 | free(p); | |
| 16 | return 0; | |
| 17 | } |
Note:
See TracBrowser
for help on using the repository browser.
