Q我写了一个小包装器围绕malloc,但它不工作
#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请参阅问题 4.8。(在这种情况下,您将需要让mymalloc返回malloc的指针。)
由 托管