summaryrefslogtreecommitdiff
path: root/3dc/win95/OUR_MEM.C
blob: 32a81ec7d9b9f31c36e87874eb823a3b631a3915 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "3dc.h"

#include <malloc.h>

#define UseLocalAssert  No

#include "ourasert.h"

#if debug
int alloc_cnt = 0;
int deall_cnt = 0;
#endif

void *AllocMem(size_t __size);
void DeallocMem(void *__ptr);

/* Note: Never use AllocMem directly !   */
/* Instead use AllocateMem() which is a  */
/* macro defined in mem3dc.h that allows */
/* for debugging info.                   */

void *AllocMem(size_t __size)
{
	GLOBALASSERT(__size>0);
	#if debug
	alloc_cnt++;	
	#endif

	return malloc(__size);
};

/* Note: Never use DeallocMem directly !  */
/* Instead use DeallocateMem() which is a */
/* macro defined in mem3dc.h that allows  */
/* for debugging info.                    */

void DeallocMem(void *__ptr)
{
	#if debug
	deall_cnt++;
	#endif

	if(__ptr) free(__ptr);

	#if debug
	else {

		textprint("ERROR - freeing null ptr\n");
		WaitForReturn();

	}
	#endif
};