source:
CIVL/examples/languageFeatures/mallocBad4.cvl@
90dd7d7
| Last change on this file since 90dd7d7 was 5252db6, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 293 bytes | |
| Line | |
|---|---|
| 1 | #include <civlc.h> |
| 2 | |
| 3 | // Reassign heap before free. |
| 4 | // This is actually illegal now since there is a limitation of |
| 5 | // one heap per scope... |
| 6 | void main() { |
| 7 | $heap h, h0; |
| 8 | double *p = (double *) $malloc(&h, 5*sizeof(double)); |
| 9 | |
| 10 | h = h0; |
| 11 | p[4]=3.14; |
| 12 | $assert(p[4]==3.14); |
| 13 | $free(&h, p); |
| 14 | } |
Note:
See TracBrowser
for help on using the repository browser.
