Skip to content

Instantly share code, notes, and snippets.

@vinipsmaker
Created October 4, 2013 18:58
Show Gist options
  • Save vinipsmaker/6830926 to your computer and use it in GitHub Desktop.
Save vinipsmaker/6830926 to your computer and use it in GitHub Desktop.
void f(const char *filename)
{
// check some conditions
if (!filename)
return;
// ... acquire some resources
int *array = malloc(sizeof(int) * /* ... */);
if (!array)
return;
FILE *f = fopen(filename);
if (!f) {
free(array);
return;
}
// Use resources
/* ... */
// Free resources
fclose(f);
free(array);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment