Back to index

wims  3.65+svn20090927
safemem.h
Go to the documentation of this file.
00001 /************************************************************************
00002  * safemem.h checking memory allocation functions
00003  *  
00004  * Copyright (c) 2005 by Ernst-G. Schmid
00005  *   
00006  * This file is part of the xchem::tigress project.
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the lesser GNU General Public License as published by
00010  * the Free Software Foundation version 2.1 of the License.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * lesser GNU General Public License for more details.
00016  ************************************************************************/
00017 
00018 #include <errno.h>
00019 #include <stdlib.h>
00020 #include <stdio.h>
00021 
00022 void *safe_calloc (size_t nmemb, size_t size) {
00023     void *p = calloc(nmemb, size);
00024     if (!p) exit(1);
00025     return p;
00026   }
00027 
00028   void *safe_malloc (size_t size) {
00029     void *p = malloc(size);
00030     if (!p) exit(1);
00031     return p;
00032   }
00033