source: CIVL/examples/library/pointer/simplePointerRealloc.cvl@ 9648a8a

1.23 2.0 main test-branch
Last change on this file since 9648a8a was 58207ec, checked in by Ziqing Luo <ziqing@…>, 10 years ago

Implement bundle_unpack_apply in CIVLC-C code
add $pointer_realloc

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@3728 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 388 bytes
Line 
1#include <pointer.cvh>
2#include <stdlib.h>
3
4/* An example shows how $pointer_realloc works. */
5int main() {
6 int * p = (int *)malloc(sizeof(int) * 10);
7
8 p[2] = 4;
9
10 $pointer_realloc(p, sizeof(int) * 12);
11
12 p[10] = 3;
13 $assert(p[2] == 4 && p[10] == 3);
14 $pointer_realloc(p, sizeof(int) * 4);
15 $assert(p[2] == 4);
16#ifdef BAD
17 $assert(p[10] == 3);
18#endif
19 free(p);
20 return 0;
21}
Note: See TracBrowser for help on using the repository browser.