summaryrefslogtreecommitdiffstats
path: root/xpa/xalloc.c
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-10-26 16:44:17 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-10-26 16:44:17 (GMT)
commit79d64f400391ce81b4eda73977cb40099256b348 (patch)
tree47afaed270cf59335dbaf4eb7965eac64a02a687 /xpa/xalloc.c
parent1377ae8b2142276c24d28d65865e459038984c62 (diff)
downloadblt-79d64f400391ce81b4eda73977cb40099256b348.zip
blt-79d64f400391ce81b4eda73977cb40099256b348.tar.gz
blt-79d64f400391ce81b4eda73977cb40099256b348.tar.bz2
upgrade XPA
Diffstat (limited to 'xpa/xalloc.c')
-rw-r--r--xpa/xalloc.c117
1 files changed, 0 insertions, 117 deletions
diff --git a/xpa/xalloc.c b/xpa/xalloc.c
deleted file mode 100644
index 18234db..0000000
--- a/xpa/xalloc.c
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2004-2009 Smithsonian Astrophysical Observatory
- */
-
-/*
- *
- * xalloc -- safe memory allocation with error checking
- *
- */
-
-/* this module is compiled within a funtools filter and must not require
- the header files */
-#ifdef FILTER_PTYPE
-#define ANSI_FUNC 1
-#else
-#include <xalloc.h>
-#endif
-
-#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
-static void _xalloc_error(void)
-#else
-static void _xalloc_error()
-#endif
-{
- write(1, XALLOC_ERROR, strlen(XALLOC_ERROR));
-#if XALLOC_SETJMP
- if( xalloc_envptr )
- longjmp(*xalloc_envptr, XALLOC_SETJMP);
- else
-#endif
- exit(1);
-}
-
-#ifdef ANSI_FUNC
-void *xmalloc(size_t n)
-#else
-void *xmalloc(n)
- size_t n;
-#endif
-{
- void *p;
-
- if( !(p = (void *)malloc(n)) )
- _xalloc_error();
- return p;
-}
-
-#ifdef ANSI_FUNC
-void *xcalloc (size_t n, size_t s)
-#else
-void *xcalloc (n, s)
- size_t n, s;
-#endif
-{
- void *p;
-
- if( !(p = (void *)calloc(n, s)) )
- _xalloc_error();
- return p;
-}
-
-#ifdef ANSI_FUNC
-void *xrealloc (void *p, size_t n)
-#else
-void *xrealloc (p, n)
- void *p;
- size_t n;
-#endif
-{
- if( !p )
- return xmalloc(n);
- if( !(p = (void *)realloc(p, n)) )
- _xalloc_error();
- return p;
-}
-
-#ifdef ANSI_FUNC
-void xfree (void *p)
-#else
-void xfree (p)
- void *p;
-#endif
-{
- if( p )
- free(p);
-}
-
-#ifdef ANSI_FUNC
-char *xstrdup (char *s)
-#else
-char *xstrdup (s)
- char *s;
-#endif
-{
- if( s )
- return((char *)strcpy((char *)xmalloc((size_t)strlen(s)+1), s));
- else
- return NULL;
-}