kirby, 6 months ago int main(void) { int *n = malloc(sizeof(int)); *n = 4; *n *= 2; *n -= 3; *n += 4; return 0; } // this shit leaks memory video/mp4
int main(void) { int *n = malloc(sizeof(int)); *n = 4; *n *= 2; *n -= 3; *n += 4; return 0; } // this shit leaks memory
video/mp4
diazepam, 6 months ago @kirby you know you can just do #include <stdlib.h> static void free_(void** p) { free(*p); } int main(void) { __attribute__((cleanup(free_))) int* n = malloc(sizeof *n); // do rest of your shit } and get it autofreed
@kirby you know you can just do
#include <stdlib.h> static void free_(void** p) { free(*p); } int main(void) { __attribute__((cleanup(free_))) int* n = malloc(sizeof *n); // do rest of your shit }
and get it autofreed
Add comment