Subversion Repositories wimsdev

Rev

Blame | Last modification | View Log | RSS feed

  1. /************************************************************************
  2.  * safemem.h checking memory allocation functions
  3.  *  
  4.  * Copyright (c) 2005 by Ernst-G. Schmid
  5.  *  
  6.  * This file is part of the xchem::tigress project.
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the lesser GNU General Public License as published by
  10.  * the Free Software Foundation version 2.1 of the License.
  11.  *
  12.  * This program is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * lesser GNU General Public License for more details.
  16.  ************************************************************************/
  17.  
  18. #include <errno.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21.  
  22. void *safe_calloc (size_t nmemb, size_t size) {
  23.     void *p = calloc(nmemb, size);
  24.     if (!p) exit(1);
  25.     return p;
  26.   }
  27.  
  28.   void *safe_malloc (size_t size) {
  29.     void *p = malloc(size);
  30.     if (!p) exit(1);
  31.     return p;
  32.   }
  33.  
  34.