Last active
April 13, 2017 17:31
-
-
Save psycho23/4060353cac8658d9b0d0f150a733674d to your computer and use it in GitHub Desktop.
Before you exit ANY C program, you want to first clear all memory so that Mr. Kernel is happy with you.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <limits.h> | |
int main(void){ | |
/* do your program here, for example: */ | |
int *p_array; | |
double *d_array; | |
p_array = (int *)malloc(sizeof(int)*50); // allocate 50 ints | |
d_array = (int *)malloc(sizeof(double)*100); // allocate 100 doubles | |
/* now, clear your memory! */ | |
for(int i=0; i<INT_MAX; i++){ | |
try{ | |
free(&i); | |
} | |
catch(SegmentationFaultException _sfex){} | |
} | |
/* SUCCESS! */ | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment