xalloc.c   xalloc.c 
/* /*
* Copyright (c) 2004 Smithsonian Astrophysical Observatory * Copyright (c) 2004-2009 Smithsonian Astrophysical Observatory
*/ */
/* /*
* *
* xalloc -- safe memory allocation with error checking * xalloc -- safe memory allocation with error checking
* *
*/ */
/* this module is compiled within a funtools filter and must not require /* this module is compiled within a funtools filter and must not require
the header files */ the header files */
#ifdef FILTER_PTYPE #ifdef FILTER_PTYPE
#define ANSI_FUNC 1 #define ANSI_FUNC 1
#else #else
#include <xalloc.h> #include <xalloc.h>
#endif #endif
#define XALLOC_ERROR "ERROR: can't allocate memory\n" #define XALLOC_ERROR "ERROR: can't allocate memory (xalloc)\n"
#if XALLOC_SETJMP
static jmp_buf *xalloc_envptr=NULL;
#ifdef ANSI_FUNC
void xalloc_savejmp(jmp_buf *env)
#else
void xalloc_savejmp(env)
jmp_buf *env;
#endif
{
xalloc_envptr = env;
}
#endif
#ifdef ANSI_FUNC #ifdef ANSI_FUNC
static void _xalloc_error(void) static void _xalloc_error(void)
#else #else
static void _xalloc_error() static void _xalloc_error()
#endif #endif
{ {
write(1, XALLOC_ERROR, strlen(XALLOC_ERROR)); write(1, XALLOC_ERROR, strlen(XALLOC_ERROR));
#if XALLOC_SETJMP
if( xalloc_envptr )
longjmp(*xalloc_envptr, XALLOC_SETJMP);
else
#endif
exit(1); exit(1);
} }
#ifdef ANSI_FUNC #ifdef ANSI_FUNC
void *xmalloc(size_t n) void *xmalloc(size_t n)
#else #else
void *xmalloc(n) void *xmalloc(n)
size_t n; size_t n;
#endif #endif
{ {
 End of changes. 3 change blocks. 
2 lines changed or deleted 22 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/