Doxygen Source Code Documentation
memory.c
Go to the documentation of this file.00001 /* 00002 * Copyright (c) 1995 The Regents of the University of California. 00003 * All rights reserved. 00004 * 00005 * Permission to use, copy, modify, and distribute this software and its 00006 * documentation for any purpose, without fee, and without written agreement is 00007 * hereby granted, provided that the above copyright notice and the following 00008 * two paragraphs appear in all copies of this software. 00009 * 00010 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR 00011 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00012 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF 00013 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00014 * 00015 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00016 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00017 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00018 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO 00019 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 00020 */ 00021 00022 /* 00023 * $Header: /misc/elrond0/share/cvs/AFNI/src/mpeg_encodedir/memory.c,v 1.4 2004/04/02 15:12:40 rwcox Exp $ 00024 * $Log: memory.c,v $ 00025 * Revision 1.4 2004/04/02 15:12:40 rwcox 00026 * Cput 00027 * 00028 * Revision 1.3 2003/12/23 13:50:08 rwcox 00029 * Cput 00030 * 00031 * Revision 1.2 2003/12/03 14:46:14 rwcox 00032 * Cput 00033 * 00034 * Revision 1.1 2001/12/17 16:11:54 rwcox 00035 * Cadd 00036 * 00037 * Revision 1.3 1995/01/19 23:08:43 eyhung 00038 * Changed copyrights 00039 * 00040 * Revision 1.2 1993/06/03 21:08:08 keving 00041 * nothing 00042 * 00043 * Revision 1.1 1993/04/27 21:32:26 keving 00044 * nothing 00045 * 00046 * 00047 */ 00048 00049 00050 #include <stdlib.h> 00051 #include <stdio.h> 00052 #include "memory.h" 00053 00054 00055 /* memory handling routines 00056 * 00057 */ 00058 00059 long totalMemory = 0; 00060 long maxMemory = 0; 00061 00062 00063 char *MemAlloc(size_t size) 00064 { 00065 totalMemory += (long)size; 00066 if ( totalMemory > maxMemory ) 00067 { 00068 maxMemory = totalMemory; 00069 } 00070 00071 return malloc(size); 00072 } 00073 00074 void MemFree(char *ptr, long bytes) 00075 { 00076 totalMemory -= bytes; 00077 free(ptr); 00078 } 00079 00080 void PrintMaxMemory(void) 00081 { 00082 fprintf(stdout, "MMMMM-----MAX MEMORY-----MMMMM = %ld\n", maxMemory); 00083 }