home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / id-utils-3.2-src.tgz / tar.out / fsf / id-utils / lib / xmalloc.h < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  47 lines

  1. /* xmalloc.h -- malloc declarations wrapper
  2.    Copyright (C) 1996 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18.  
  19. #ifndef _xmalloc_h_
  20. #define _xmalloc_h_ 1
  21.  
  22. #include <sys/types.h>
  23.  
  24. #if HAVE_CONFIG_H
  25. # include <config.h>
  26. #endif
  27. #if defined STDC_HEADERS || defined _LIBC || defined HAVE_STDLIB_H
  28. # include <stdlib.h>
  29. #endif
  30. #if HAVE_MALLOC_H
  31. # include <malloc.h>
  32. #else
  33. void free ();
  34. #endif
  35.  
  36. void *xmalloc __P((size_t n));
  37. void *xrealloc __P((void *p, size_t n));
  38.  
  39. #include "xstring.h"
  40.  
  41. #define    CALLOC(t, n) ((t *) calloc (sizeof (t), (n)))
  42. #define MALLOC(t, n) ((t *) xmalloc (sizeof (t) * (n)))
  43. #define REALLOC(o, t, n) ((t *) xrealloc ((o), sizeof (t) * (n)))
  44. #define CLONE(o, t, n) ((t *) memcpy (MALLOC (t, (n)), (o), sizeof (t) * (n)))
  45.  
  46. #endif /* _xmalloc_h_ */
  47.