⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mallocs.c

📁 端口扫描源代码
💻 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 + -