Making panels stacking order aware of launcher alignment
[chromium-blink-merge.git] / third_party / lzma_sdk / 7zAlloc.c
blob964b28db38ec8f18ca7209e121258399a7ba56ed
1 /* 7zAlloc.c -- Allocation functions
2 2010-10-29 : Igor Pavlov : Public domain */
4 #include "7zAlloc.h"
6 /* #define _SZ_ALLOC_DEBUG */
7 /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
9 #ifdef _SZ_ALLOC_DEBUG
11 #ifdef _WIN32
12 #include <windows.h>
13 #endif
15 #include <stdio.h>
16 int g_allocCount = 0;
17 int g_allocCountTemp = 0;
19 #endif
21 void *SzAlloc(void *p, size_t size)
23 p = p;
24 if (size == 0)
25 return 0;
26 #ifdef _SZ_ALLOC_DEBUG
27 fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount);
28 g_allocCount++;
29 #endif
30 return malloc(size);
33 void SzFree(void *p, void *address)
35 p = p;
36 #ifdef _SZ_ALLOC_DEBUG
37 if (address != 0)
39 g_allocCount--;
40 fprintf(stderr, "\nFree; count = %10d", g_allocCount);
42 #endif
43 free(address);
46 void *SzAllocTemp(void *p, size_t size)
48 p = p;
49 if (size == 0)
50 return 0;
51 #ifdef _SZ_ALLOC_DEBUG
52 fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp);
53 g_allocCountTemp++;
54 #ifdef _WIN32
55 return HeapAlloc(GetProcessHeap(), 0, size);
56 #endif
57 #endif
58 return malloc(size);
61 void SzFreeTemp(void *p, void *address)
63 p = p;
64 #ifdef _SZ_ALLOC_DEBUG
65 if (address != 0)
67 g_allocCountTemp--;
68 fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);
70 #ifdef _WIN32
71 HeapFree(GetProcessHeap(), 0, address);
72 return;
73 #endif
74 #endif
75 free(address);