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

📄 memalloc.h

📁 一个学习SNMP项目:tmoerlan.
💻 H
字号:
/* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks. * * memalloc.h : macros for doing memory allocation. Each allocation *   checks for successful allocation, and exits upon failure. Macro *   is used mainly for code readability. * * $Id: memalloc.h,v 1.2 2003/09/17 11:26:10 tmoerlan Exp $ */#ifndef _SNAP_MEMALLOC_H_#define _SNAP_MEMALLOC_H_#include <stdio.h>#include <stdlib.h>#include <string.h>#include "timers.h"#ifdef NONZERO_MALLOC#define memalloc(ptr,t,sz)                                        \  { void *_result;                                                \    print_anti_timer(12,"memalloc");                              \    _result = (void *)malloc(sz);                                 \    if (_result == NULL) {                                        \      fprintf(stderr,"%s:%d: malloc failed\n",__FILE__,__LINE__); \      fflush(stderr);                                             \      exit(1);                                                    \    }                                                             \    (ptr) = (t)_result;                                           \    print_timer(12,"memalloc");                                   \  } #else#define memalloc(ptr,t,sz)                                        \  { void *_result;                                                \    print_anti_timer(12,"memalloc");                              \    _result = (void *)malloc(sz);                                 \    if (_result == NULL) {                                        \      fprintf(stderr,"%s:%d: malloc failed\n",__FILE__,__LINE__); \      fflush(stderr);                                             \      exit(1);                                                    \    }                                                             \    bzero(_result,sz);                                            \    (ptr) = (t)_result;                                           \    print_timer(12,"memalloc");                                   \} #endif /* NONZERO_MALLOC */#endif /* _SNAP_MEMALLOC_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -