📄 alloc.c
字号:
/***********************************************************************\* Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com ** ** This file is placed under the conditions of the GNU Library ** General Public License, version 2, or any later version. ** See file ../COPYING.LIB for information on distribution ** conditions. *\***********************************************************************/#include <stdlib.h>#include <stdio.h>void *xcalloc(void *pointer, int size) { void * ret; if (pointer) free(pointer); if (!(ret = calloc(1, size))) { fprintf(stderr, "xcalloc: allocation error, size = %d\n", size); exit(1); } else { return ret; }}void *xmalloc(unsigned int size) { void *p; if (size == 0) ++size; p = malloc(size); if (!p) { fprintf(stderr, "xmalloc: malloc(%d) failed", size); perror(NULL); exit(1); } return(p);}void *xrealloc(void *oldp, unsigned int size) { void *p; if (size == 0) ++size; p = realloc(oldp, size); if (!p) { fprintf(stderr, "xrealloc: realloc(%d) failed", size); perror(NULL); exit(1); } return(p);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -