Annotation of elwix/tools/oldlzma/SRC/7zip/Archive/7z_C/7zAlloc.c, revision 1.1.1.1
1.1 misho 1: /* 7zAlloc.c */
2:
3: #include <stdlib.h>
4: #include "7zAlloc.h"
5:
6: /* #define _SZ_ALLOC_DEBUG */
7: /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
8:
9: #ifdef _SZ_ALLOC_DEBUG
10: #include <stdio.h>
11: int g_allocCount = 0;
12: int g_allocCountTemp = 0;
13: #endif
14:
15: void *SzAlloc(size_t size)
16: {
17: #ifdef _SZ_ALLOC_DEBUG
18: fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
19: g_allocCount++;
20: #endif
21: return malloc(size);
22: }
23:
24: void SzFree(void *address)
25: {
26: #ifdef _SZ_ALLOC_DEBUG
27: if (address != 0)
28: {
29: g_allocCount--;
30: fprintf(stderr, "\nFree; count = %10d", g_allocCount);
31: }
32: #endif
33: free(address);
34: }
35:
36: void *SzAllocTemp(size_t size)
37: {
38: #ifdef _SZ_ALLOC_DEBUG
39: fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
40: g_allocCountTemp++;
41: #endif
42: return malloc(size);
43: }
44:
45: void SzFreeTemp(void *address)
46: {
47: #ifdef _SZ_ALLOC_DEBUG
48: if (address != 0)
49: {
50: g_allocCountTemp--;
51: fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);
52: }
53: #endif
54: free(address);
55: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>