본문 바로가기

컴퓨터 과학 & 영상처리 관련/자료구조 / 알고리즘

MALLOC

#define MALLOC(p,s) if(!((p)=malloc(s))){fprintf(stderr,"메모리 충분치않음"); exit(EXIT_FAILURE);}

#define CALLOC(p, n, s)\
 if(!((p) = calloc(n, s))) {\
  fprintf(stderr, "Insufficient memory");\
  exit(EXIT_FAILURE);\

#define MALLOC(p,t,s)  if(!((p) = (t*)malloc(s))) { fprintf(stderr, "Insufficient memory"); exit(EXIT_FAILURE); }

MALLOC(pi, int, sizeof(int));