Commit 37b3fc7f4290abffd51f486d8f02e5f8953bf6e9
1 parent
e4f342c16e
Exists in
master
add leak
Showing 1 changed file with 13 additions and 0 deletions Inline Diff
lab2/leak.c
View file @
37b3fc7
| File was created | 1 | #include <stdlib.h> | ||
| 2 | #include <stdio.h> | |||
| 3 | void f(void) | |||
| 4 | { | |||
| 5 | int* x = (int*)malloc(10 * sizeof(int)); | |||
| 6 | x[9] = 2; | |||
| 7 | } // problem: memory leak -- x not freed | |||
| 8 | int main(int argc, char * argv[]) | |||
| 9 | { | |||
| 10 | f(); | |||
| 11 | printf("GOOD END \n"); | |||
| 12 | return 0; | |||
| 13 | } |