home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / misc / aspringies-1.0.lha / ASpringies / src / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-24  |  1.7 KB  |  61 lines

  1. /* misc.c -- misc utility routines for ASpringies
  2.  * Copyright (C) 1991  Douglas M. DeCarlo
  3.  *
  4.  * Modifications for the Amiga port Copyright (C) 1994  Torsten Klein
  5.  *
  6.  * This file is part of ASpringies, a mass and spring simulation system for the Amiga
  7.  *
  8.  * ASpringies is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 1, or (at your option)
  11.  * any later version.
  12.  *
  13.  * ASpringies is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with ASpringies; see the file COPYING.  If not, write to
  20.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  * $Id: misc.c,v 1.5 1994/06/26 20:42:58 Torsten_Klein Exp $
  23.  */
  24.  
  25. #include "defs.h"
  26. #include "main.h"
  27.  
  28. /* malloc space, and call main_fail if allocation fails 
  29.  */
  30. char *xmalloc (int size)
  31. {
  32.   register char *tmp = (char *)malloc(size);
  33.  
  34.   if (!tmp) {
  35.     delete_all();
  36.     main_fail("memory for dynamic arrays (xmalloc)", __FILE__, __LINE__);
  37.   }
  38.   return tmp;
  39. }
  40.  
  41. /* realloc space, and call main_fail if re-allocation fails
  42.  *   (also, call malloc if ptr is NULL) 
  43.  */
  44. char *xrealloc (char *ptr, int size)
  45. {
  46.   register char *tmp;
  47.  
  48.   if (ptr == NULL)
  49.     return (char *)xmalloc(size);
  50.  
  51.   tmp = (char *)realloc(ptr, size);
  52.   
  53.   if (!tmp) {
  54.     delete_all();
  55.     main_fail("memory for dynamic arrays (xrealloc)", __FILE__, __LINE__);
  56.   }
  57.   return tmp;
  58. }
  59.  
  60.  
  61.