00001 /* 00002 00003 The BLAH library, a container library 00004 Copyright (C) 1997-2004 The CDG Team <cdg@nats.informatik.uni-hamburg.de> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 00020 Contact: blah@nats.informatik.uni-hamburg.de 00021 00022 $Id: memory.c,v 1.3 2004/03/23 14:21:58 micha Exp $ 00023 00024 */ 00025 /*-----------------------------------------------------------------------*/ 00026 00027 /* ---------------------------------------------------------------------- 00028 * @defgroup Memory Memory 00029 * Some basic Operations with the memory are done in this module. 00030 * @{ 00031 */ 00032 00033 #include <stdio.h> 00034 #include "blah.h" 00035 00036 /* ---------------------------------------------------------------------- 00037 * used for checking the memory allocation for pointers. 00038 * 00039 * a function that checks whether pointer is NULL, used by 00040 * a version of memMalloc (c. f. memMalloc.h) 00041 * 00042 * @param ptr the ptr whose value has to be checked for NULL. 00043 * @param file the file that contains the pointer. 00044 * @param line the line in which the pointer exists. 00045 * @returns error message if pointer equals null else returns the pointer. 00046 */ 00047 void *memMallocCheck(void *ptr, char *file, int line) 00048 { 00049 if (ptr == NULL) 00050 { 00051 fprintf(stderr, "ERROR: %s:%d: no memory left\n", file, line); 00052 abort(); 00053 } 00054 return (ptr); 00055 } 00056 00057 /* ---------------------------------------------------------------------- 00058 * sometimes memFree must be a function 00059 * 00060 * @param pointer the pointer that determines the memory free function. 00061 */ 00062 void memFreeFunction( void *pointer ) 00063 { 00064 memFree( pointer ); 00065 }