Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

xmalloc.c

Go to the documentation of this file.
00001 /***************************************************************************
00002                                   xmalloc.c
00003                              -------------------
00004     begin                : Sun Nov 4 2001
00005     copyright            : (C) 2001-2002 by Christian Hoenig & Gunter Ohrner
00006     email                : pdepp@CustomCDROM.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00022 #include "common.h"
00023 
00024 #include <errno.h>
00025 #include <stdlib.h>
00026 #include <stdio.h>
00027 
00028 #ifdef WITH_MPATROL
00029 # include <mpatrol.h>
00030 #endif
00031 
00032 #include "xmalloc.h"
00033 
00034 
00035 // simple realloc()
00036 void* pd_realloc(void* ptr, size_t size)
00037 {
00038   return realloc(ptr, size);
00039 }
00040 
00041 
00042 // simple malloc, but program exits, if malloc fails
00043 void* pd_malloc(size_t size)
00044 {
00045   void *tmp = malloc(size);
00046   if (tmp == NULL)
00047   {
00048     //if malloc fails, the program exits,
00049     //to give resources to the system back on that dramatic situation
00050     perror("xmalloc");
00051     exit(EXIT_FAILURE);
00052   }
00053   else
00054     return tmp;
00055 }
00056 
00057 
00058 // simple free()
00059 void pd_free(void *ptr)
00060 {
00061   //ptr is only freed, if ptr is not NULL
00062   if (ptr != NULL)
00063     free(ptr);
00064 }
00065 

Generated on Fri Jan 25 22:40:31 2002 for PDepp Webserver by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001