Fix "no remove aqua speed" bug when player leaves the water
[ryzomcore.git] / nel / 3rdparty / seven_zip / 7zAlloc.c
blobc924a529fa8724793ad2420183bacfbe26afcf28
1 /* 7zAlloc.c -- Allocation functions
2 2017-04-03 : Igor Pavlov : Public domain */
4 #include "Precomp.h"
6 #include <stdlib.h>
8 #include "7zAlloc.h"
10 /* #define _SZ_ALLOC_DEBUG */
11 /* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
13 #ifdef _SZ_ALLOC_DEBUG
15 #ifdef _WIN32
16 #include <windows.h>
17 #endif
19 #include <stdio.h>
20 int g_allocCount = 0;
21 int g_allocCountTemp = 0;
23 #endif
25 void *SzAlloc(ISzAllocPtr p, size_t size)
27 UNUSED_VAR(p);
28 if (size == 0)
29 return 0;
30 #ifdef _SZ_ALLOC_DEBUG
31 fprintf(stderr, "\nAlloc %10u bytes; count = %10d", (unsigned)size, g_allocCount);
32 g_allocCount++;
33 #endif
34 return malloc(size);
37 void SzFree(ISzAllocPtr p, void *address)
39 UNUSED_VAR(p);
40 #ifdef _SZ_ALLOC_DEBUG
41 if (address != 0)
43 g_allocCount--;
44 fprintf(stderr, "\nFree; count = %10d", g_allocCount);
46 #endif
47 free(address);
50 void *SzAllocTemp(ISzAllocPtr p, size_t size)
52 UNUSED_VAR(p);
53 if (size == 0)
54 return 0;
55 #ifdef _SZ_ALLOC_DEBUG
56 fprintf(stderr, "\nAlloc_temp %10u bytes; count = %10d", (unsigned)size, g_allocCountTemp);
57 g_allocCountTemp++;
58 #ifdef _WIN32
59 return HeapAlloc(GetProcessHeap(), 0, size);
60 #endif
61 #endif
62 return malloc(size);
65 void SzFreeTemp(ISzAllocPtr p, void *address)
67 UNUSED_VAR(p);
68 #ifdef _SZ_ALLOC_DEBUG
69 if (address != 0)
71 g_allocCountTemp--;
72 fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp);
74 #ifdef _WIN32
75 HeapFree(GetProcessHeap(), 0, address);
76 return;
77 #endif
78 #endif
79 free(address);