[insert project logo here (125x200px max)] Navigator Mailinglists Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums. Copyright and Licensing Information Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL). All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License. All sourcecode is made publicly available. Acknowledgement Splash and the Splash website are hosted by SourceForge.net |
Splash - DocumentationSNMP Plus a Lightweight API for SNAP Handlingsnap-1.1-wjdb/lib/memalloc.hGo to the documentation of this file.00001 /* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks. 00002 * 00003 * memalloc.h : macros for doing memory allocation. Each allocation 00004 * checks for successful allocation, and exits upon failure. Macro 00005 * is used mainly for code readability. 00006 * 00007 * $Id: memalloc.h,v 1.1.1.1 2002/12/04 18:59:42 wdebruij Exp $ 00008 */ 00009 00010 #ifndef _SNAP_MEMALLOC_H_ 00011 #define _SNAP_MEMALLOC_H_ 00012 00013 #include <stdio.h> 00014 #include <stdlib.h> 00015 #include <string.h> 00016 #include "timers.h" 00017 00018 #ifdef NONZERO_MALLOC 00019 #define memalloc(ptr,t,sz) \ 00020 { void *_result; \ 00021 print_anti_timer(12,"memalloc"); \ 00022 _result = (void *)malloc(sz); \ 00023 if (_result == NULL) { \ 00024 fprintf(stderr,"%s:%d: malloc failed\n",__FILE__,__LINE__); \ 00025 fflush(stderr); \ 00026 exit(1); \ 00027 } \ 00028 (ptr) = (t)_result; \ 00029 print_timer(12,"memalloc"); \ 00030 } 00031 #else 00032 #define memalloc(ptr,t,sz) \ 00033 { void *_result; \ 00034 print_anti_timer(12,"memalloc"); \ 00035 _result = (void *)malloc(sz); \ 00036 if (_result == NULL) { \ 00037 fprintf(stderr,"%s:%d: malloc failed\n",__FILE__,__LINE__); \ 00038 fflush(stderr); \ 00039 exit(1); \ 00040 } \ 00041 bzero(_result,sz); \ 00042 (ptr) = (t)_result; \ 00043 print_timer(12,"memalloc"); \ 00044 } 00045 #endif /* NONZERO_MALLOC */ 00046 #endif /* _SNAP_MEMALLOC_H_ */ |