Q: I wrote a little wrapper around malloc, but it doesn't work:
#include <stdio.h>
#include <stdlib.h>
mymalloc(void *retp, size_t size)
{
retp = malloc(size);
if(retp == NULL) {
fprintf(stderr, "out of memory\n");
exit(EXIT_FAILURE);
}
}
A: See question 4.8. (In this case, you'll want to have mymalloc return the malloc'ed pointer.)