source:
CIVL/examples/languageFeatures/mallocBad3.cvl@
32410ee
| Last change on this file since 32410ee was 924c81b, checked in by , 12 years ago | |
|---|---|
|
|
| File size: 299 bytes | |
| Rev | Line | |
|---|---|---|
| [36b5ada] | 1 | /* Commandline execution: |
| 2 | * civl verify mallocBad3.cvl | |
| 3 | * */ | |
| [1f192b0] | 4 | #include <civlc.h> |
| 5 | void main() { | |
| [924c81b] | 6 | $heap h = $heap_create(), h0 = $heap_create(); |
| 7 | double *p = (double *) $malloc(h, 5*sizeof(double)); | |
| [1f192b0] | 8 | |
| 9 | p[4]=3.14; | |
| 10 | $assert(p[4]==3.14); | |
| [36b5ada] | 11 | // Free pointer from the wrong heap. |
| [924c81b] | 12 | $free(h0, p); |
| [1f192b0] | 13 | } |
Note:
See TracBrowser
for help on using the repository browser.
