1 |
/* |
2 |
* Copyright (c) 1995 The Regents of the University of California. |
3 |
* All rights reserved. |
4 |
* |
5 |
* Permission to use, copy, modify, and distribute this software and its |
6 |
* documentation for any purpose, without fee, and without written agreement is |
7 |
* hereby granted, provided that the above copyright notice and the following |
8 |
* two paragraphs appear in all copies of this software. |
9 |
* |
10 |
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR |
11 |
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT |
12 |
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF |
13 |
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
14 |
* |
15 |
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, |
16 |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY |
17 |
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
18 |
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO |
19 |
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
20 |
*/ |
21 |
|
22 |
/* |
23 |
* $Header: /n/charlie-brown/project/mm/mpeg/mpeg_dist/mpeg_encode/RCS/memory.c,v 1.3 1995/01/19 23:08:43 eyhung Exp $ |
24 |
* $Log: memory.c,v $ |
25 |
* Revision 1.3 1995/01/19 23:08:43 eyhung |
26 |
* Changed copyrights |
27 |
* |
28 |
* Revision 1.2 1993/06/03 21:08:08 keving |
29 |
* nothing |
30 |
* |
31 |
* Revision 1.1 1993/04/27 21:32:26 keving |
32 |
* nothing |
33 |
* |
34 |
* |
35 |
*/ |
36 |
|
37 |
|
38 |
#include <stdlib.h> |
39 |
#include <stdio.h> |
40 |
#include "memory.h" |
41 |
|
42 |
|
43 |
/* memory handling routines |
44 |
* |
45 |
*/ |
46 |
|
47 |
long totalMemory = 0; |
48 |
long maxMemory = 0; |
49 |
|
50 |
|
51 |
char *MemAlloc(size_t size) |
52 |
{ |
53 |
totalMemory += (long)size; |
54 |
if ( totalMemory > maxMemory ) |
55 |
{ |
56 |
maxMemory = totalMemory; |
57 |
} |
58 |
|
59 |
return malloc(size); |
60 |
} |
61 |
|
62 |
void MemFree(char *ptr, long bytes) |
63 |
{ |
64 |
totalMemory -= bytes; |
65 |
free(ptr); |
66 |
} |
67 |
|
68 |
void PrintMaxMemory(void) |
69 |
{ |
70 |
fprintf(stdout, "MMMMM-----MAX MEMORY-----MMMMM = %ld\n", maxMemory); |
71 |
} |