?? mallocs.c
字號:
/* * mymalloc, myrealloc, dupstr - memory allocation with error handling * * Environment: POSIX, ANSI * * Author: Wietse Venema. */#include <stdlib.h>#include <unistd.h>#include <string.h>#include "lib.h"/* mymalloc - allocate memory or bust */char *mymalloc(len)int len;{ char *ptr; if ((ptr = malloc(len)) == 0) error("Insufficient memory: %m"); return (ptr);}/* myrealloc - reallocate memory or bust */char *myrealloc(ptr, len)char *ptr;int len;{ if ((ptr = realloc(ptr, len)) == 0) error("Insufficient memory: %m"); return (ptr);}/* dupstr - save string to heap */char *dupstr(str)char *str;{ return (strcpy(mymalloc(strlen(str) + 1), str));}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -