source:
CIVL/examples/languageFeatures/mallocBad4.cvl@
38b7d06
| Last change on this file since 38b7d06 was 5252db6, checked in by , 13 years ago | |
|---|---|
|
|
| File size: 293 bytes | |
| Rev | Line | |
|---|---|---|
| [1f192b0] | 1 | #include <civlc.h> |
| 2 | ||
| 3 | // Reassign heap before free. | |
| [5252db6] | 4 | // This is actually illegal now since there is a limitation of |
| 5 | // one heap per scope... | |
| [1f192b0] | 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.
