📄 alloc.c
字号:
/**********Copyright 1990 Regents of the University of California. All rights reserved.**********//* * Memory alloction functions */#include "spice.h"#include "stdio.h"#include "misc.h"#include "suffix.h"/* Malloc num bytes and initialize to zero. Fatal error if the space can't * be malloc'd. Return NULL for a request for 0 bytes. */char *tmalloc(num) int num;{ char *s; if (!num) return NULL; s = malloc((unsigned) num); if (!s) { fprintf(stderr, "malloc: Internal Error: can't allocate %d bytes.\n", num); exit(EXIT_BAD); } bzero(s, num); return(s);}char *trealloc(str, num) char *str; int num;{ char *s; if (!num) { if (str) free(str); return NULL; } if (!str) s = tmalloc(num); else s = realloc(str, (unsigned) num); if (!s) { fprintf(stderr, "realloc: Internal Error: can't allocate %d bytes.\n", num); exit(EXIT_BAD); } return(s);}voidtxfree(ptr) char *ptr;{ if (ptr) free(ptr);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -