source: CIVL/examples/languageFeatures/mallocBad4.cvl@ 1c1b91a

1.23 2.0 main test-branch
Last change on this file since 1c1b91a was 1f192b0, checked in by Tim Zirkel <zirkeltk@…>, 13 years ago

Added some examples of improper malloc use.

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

  • Property mode set to 100644
File size: 205 bytes
Line 
1#include <civlc.h>
2
3// Reassign heap before free.
4void main() {
5 $heap h, h0;
6 double *p = (double *) $malloc(&h, 5*sizeof(double));
7
8 h = h0;
9 p[4]=3.14;
10 $assert(p[4]==3.14);
11 $free(&h, p);
12}
Note: See TracBrowser for help on using the repository browser.