Skip to content

Instantly share code, notes, and snippets.

/sample.c Secret

Created December 25, 2015 12:09
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 anonymous/ff8f49c8c531524cd389 to your computer and use it in GitHub Desktop.
Save anonymous/ff8f49c8c531524cd389 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
int allocate(ANY_TYPE **p,
size_t s)
{
if ((*p = malloc(s)) == NULL) {
fputs("Error: malloc();\n", stderr);
return -1;
}
return 0;
}
int main(void)
{
int *p;
int r = allocate(&p, sizeof *p);
if (r != 0)
return EXIT_FAILURE;
free(p);
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment