diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2021-12-27 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-03-18 15:35:13 +0500 |
commit | f19f813537c7aea1c20749c914e756b54a9c3cf5 (patch) | |
tree | 816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /C/Alloc.h | |
parent | 98e06a519b63b81986abe76d28887f6984a7732b (diff) | |
download | 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.gz 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.tar.bz2 7zip-f19f813537c7aea1c20749c914e756b54a9c3cf5.zip |
'21.07'21.07
Diffstat (limited to 'C/Alloc.h')
-rw-r--r-- | C/Alloc.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/C/Alloc.h b/C/Alloc.h new file mode 100644 index 0000000..3be2041 --- /dev/null +++ b/C/Alloc.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /* Alloc.h -- Memory allocation functions | ||
2 | 2021-07-13 : Igor Pavlov : Public domain */ | ||
3 | |||
4 | #ifndef __COMMON_ALLOC_H | ||
5 | #define __COMMON_ALLOC_H | ||
6 | |||
7 | #include "7zTypes.h" | ||
8 | |||
9 | EXTERN_C_BEGIN | ||
10 | |||
11 | void *MyAlloc(size_t size); | ||
12 | void MyFree(void *address); | ||
13 | |||
14 | #ifdef _WIN32 | ||
15 | |||
16 | void SetLargePageSize(void); | ||
17 | |||
18 | void *MidAlloc(size_t size); | ||
19 | void MidFree(void *address); | ||
20 | void *BigAlloc(size_t size); | ||
21 | void BigFree(void *address); | ||
22 | |||
23 | #else | ||
24 | |||
25 | #define MidAlloc(size) MyAlloc(size) | ||
26 | #define MidFree(address) MyFree(address) | ||
27 | #define BigAlloc(size) MyAlloc(size) | ||
28 | #define BigFree(address) MyFree(address) | ||
29 | |||
30 | #endif | ||
31 | |||
32 | extern const ISzAlloc g_Alloc; | ||
33 | |||
34 | #ifdef _WIN32 | ||
35 | extern const ISzAlloc g_BigAlloc; | ||
36 | extern const ISzAlloc g_MidAlloc; | ||
37 | #else | ||
38 | #define g_BigAlloc g_AlignedAlloc | ||
39 | #define g_MidAlloc g_AlignedAlloc | ||
40 | #endif | ||
41 | |||
42 | extern const ISzAlloc g_AlignedAlloc; | ||
43 | |||
44 | |||
45 | typedef struct | ||
46 | { | ||
47 | ISzAlloc vt; | ||
48 | ISzAllocPtr baseAlloc; | ||
49 | unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */ | ||
50 | size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */ | ||
51 | } CAlignOffsetAlloc; | ||
52 | |||
53 | void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p); | ||
54 | |||
55 | |||
56 | EXTERN_C_END | ||
57 | |||
58 | #endif | ||