Skip to content

Instantly share code, notes, and snippets.

@swilly22
Last active September 15, 2019 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swilly22/2fbffb6a51250e0e0ecf76985faa32e2 to your computer and use it in GitHub Desktop.
Save swilly22/2fbffb6a51250e0e0ecf76985faa32e2 to your computer and use it in GitHub Desktop.
void f(void) {
void *a = NULL;
void *b = NULL;
void *c = NULL;
a = malloc(32);
//...
if(cond1) goto cleanup;
b = malloc(64);
//...
if(cond2) goto cleanup;
c = malloc(128);
//...
cleanup:
if(a) free(a);
if(b) free(b);
if(c) free(c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment