home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / GRAPHICS / rayshade.lzh / memory.c < prev    next >
Text File  |  1990-05-08  |  2KB  |  78 lines

  1. /*
  2.  * memory.c
  3.  *
  4.  * Copyright (C) 1989, Craig E. Kolb
  5.  *
  6.  * This software may be freely copied, modified, and redistributed,
  7.  * provided that this copyright notice is preserved on all copies.
  8.  *
  9.  * There is no warranty or other guarantee of fitness for this software,
  10.  * it is provided solely .  Bug reports or fixes may be sent
  11.  * to the author, who may or may not act on them as he desires.
  12.  *
  13.  * You may not include this software in a program or other software product
  14.  * without supplying the source, or without informing the end-user that the
  15.  * source is available for no extra charge.
  16.  *
  17.  * If you modify this software, you should include a notice giving the
  18.  * name of the person performing the modification, the date of modification,
  19.  * and the reason for such modification.
  20.  *
  21.  * $Id: memory.c,v 3.0.1.2 90/04/04 18:56:08 craig Exp $
  22.  *
  23.  * $Log:    memory.c,v $
  24.  * Revision 3.0.1.2  90/04/04  18:56:08  craig
  25.  * patch5: Lint removal.
  26.  * 
  27.  * Revision 3.0.1.1  89/12/06  16:33:59  craig
  28.  * patch2: Added calls to new error/warning routines.
  29.  * 
  30.  * Revision 3.0  89/10/27  02:05:56  craig
  31.  * Baseline for first official release.
  32.  * 
  33.  */
  34. #include <stdio.h>
  35. #ifdef SYSV
  36. #include <memory.h>
  37. #endif
  38. #include "typedefs.h"
  39. #include "funcdefs.h"
  40.  
  41. unsigned long TotalAllocated;
  42.  
  43. char *
  44. Malloc(bytes)
  45. unsigned bytes;
  46. {
  47.     char *res, *malloc();
  48.  
  49.     TotalAllocated += bytes;
  50.  
  51.     res = malloc(bytes);
  52.     if (res == (char *)0)
  53.         RSerror("Out of memory trying to allocate %d bytes.\n",bytes);
  54.     return res;
  55. }
  56.  
  57. char *
  58. Calloc(nelem, elen)
  59. unsigned nelem, elen;
  60. {
  61.     char *res;
  62.  
  63.     res = Malloc(nelem*elen);
  64. #ifdef SYSV
  65.     (void)memset(res, (char)0, (int)(nelem*elen));
  66. #else
  67.     bzero(res, (int)nelem*elen);
  68. #endif
  69.     return res;
  70. }
  71.  
  72. PrintMemoryStats()
  73. {
  74.     extern FILE *fstats;
  75.  
  76.     fprintf(fstats,"Total memory allocated:\t\t%d bytes\n",TotalAllocated);
  77. }
  78.