Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
Alloc.h
Go to the documentation of this file.
1/* Alloc.h -- Memory allocation functions
22023-03-04 : Igor Pavlov : Public domain */
3
4#ifndef ZIP7_INC_ALLOC_H
5#define ZIP7_INC_ALLOC_H
6
7#include "7zTypes.h"
8
10
11/*
12 MyFree(NULL) : is allowed, as free(NULL)
13 MyAlloc(0) : returns NULL : but malloc(0) is allowed to return NULL or non_NULL
14 MyRealloc(NULL, 0) : returns NULL : but realloc(NULL, 0) is allowed to return NULL or non_NULL
15MyRealloc() is similar to realloc() for the following cases:
16 MyRealloc(non_NULL, 0) : returns NULL and always calls MyFree(ptr)
17 MyRealloc(NULL, non_ZERO) : returns NULL, if allocation failed
18 MyRealloc(non_NULL, non_ZERO) : returns NULL, if reallocation failed
19*/
20
21void *MyAlloc(size_t size);
22void MyFree(void *address);
23void *MyRealloc(void *address, size_t size);
24
25#ifdef _WIN32
26
27#ifdef Z7_LARGE_PAGES
28void SetLargePageSize(void);
29#endif
30
31void *MidAlloc(size_t size);
32void MidFree(void *address);
33void *BigAlloc(size_t size);
34void BigFree(void *address);
35
36#else
37
38#define MidAlloc(size) MyAlloc(size)
39#define MidFree(address) MyFree(address)
40#define BigAlloc(size) MyAlloc(size)
41#define BigFree(address) MyFree(address)
42
43#endif
44
45extern const ISzAlloc g_Alloc;
46
47#ifdef _WIN32
48extern const ISzAlloc g_BigAlloc;
49extern const ISzAlloc g_MidAlloc;
50#else
51#define g_BigAlloc g_AlignedAlloc
52#define g_MidAlloc g_AlignedAlloc
53#endif
54
55extern const ISzAlloc g_AlignedAlloc;
56
57
58typedef struct
59{
60 ISzAlloc vt;
61 ISzAllocPtr baseAlloc;
62 unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */
63 size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */
65
67
68
70
71#endif
#define EXTERN_C_BEGIN
Definition 7zTypes.h:20
#define EXTERN_C_END
Definition 7zTypes.h:21
EXTERN_C_BEGIN void * MyAlloc(size_t size)
Definition Alloc.c:169
const ISzAlloc g_AlignedAlloc
Definition Alloc.c:492
#define g_MidAlloc
Definition Alloc.h:57
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p)
Definition Alloc.c:601
#define BigFree(address)
Definition Alloc.h:46
#define MidFree(address)
Definition Alloc.h:44
#define g_BigAlloc
Definition Alloc.h:56
void * MyRealloc(void *address, size_t size)
Definition Alloc.c:195
const ISzAlloc g_Alloc
Definition Alloc.c:325
#define BigAlloc(size)
Definition Alloc.h:45
#define MidAlloc(size)
Definition Alloc.h:43
void MyFree(void *address)
Definition Alloc.c:188
Definition Alloc.h:64
Definition 7zTypes.h:460
size_t size
Definition platform.h:559