Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

xalloc.c

Go to the documentation of this file.
00001 /*
00002  *  File:       xalloc.c
00003  *              $Id: xalloc.c,v 1.3 2002/06/05 21:37:14 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  * 
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: xalloc.c,v $
00012  *  Revision 1.3  2002/06/05 21:37:14  alec
00013  *  gcc happy
00014  *
00015  *  Revision 1.2  2002/04/29 09:34:10  alec
00016  *  scanner ptree building compiles
00017  *
00018  */
00019 
00020 /*
00021   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00022 
00023   This program is free software; you can redistribute it and/or modify
00024   it under the terms of the GNU General Public License as published by
00025   the Free Software Foundation; either version 2 of the License, or
00026   (at your option) any later version.
00027 
00028   This program is distributed in the hope that it will be useful,
00029   but WITHOUT ANY WARRANTY; without even the implied warranty of
00030   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00031   GNU General Public License for more details.
00032 
00033   You should have received a copy of the GNU General Public License
00034   along with this program; if not, write to the Free Software
00035   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00036 
00037  */
00038 
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include "debug.h"
00042 #include "xalloc.h"
00043 
00044 
00045 void *xcalloc(size_t nmemb, size_t size)
00046 {
00047   void *res = calloc(nmemb, size);
00048   if (!res) RUNTIME_ERROR("calloc failed.");
00049   return res;
00050 }
00051 
00052 
00053 void *xmalloc(size_t size)
00054 {
00055   void *res = malloc(size);
00056   if (!res) RUNTIME_ERROR("malloc failed.");
00057   return res;
00058 }
00059 
00060 void xfree(void **ptr)
00061 {
00062   free(*ptr);
00063   *ptr = NULL;
00064 }
00065 
00066 void *xrealloc(void *ptr, size_t size)
00067 {
00068   void *res = realloc(ptr, size);
00069   if (!res) RUNTIME_ERROR("realloc failed.");
00070   return res;
00071 }
00072 
00073 
00074 char *xstrdup(const char *s)
00075 {
00076   char *res = (char*) strdup(s);
00077   if (!res) RUNTIME_ERROR("realloc failed.");
00078   return res;
00079 }

Generated at Tue Jul 9 21:05:46 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001