Alloc.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Alloc.h -- Memory allocation functions
  2. 2018-02-19 : Igor Pavlov : Public domain */
  3. #ifndef __COMMON_ALLOC_H
  4. #define __COMMON_ALLOC_H
  5. #include "7zTypes.h"
  6. EXTERN_C_BEGIN
  7. void *MyAlloc(size_t size);
  8. void MyFree(void *address);
  9. #ifdef _WIN32
  10. void SetLargePageSize();
  11. void *MidAlloc(size_t size);
  12. void MidFree(void *address);
  13. void *BigAlloc(size_t size);
  14. void BigFree(void *address);
  15. #else
  16. #define MidAlloc(size) MyAlloc(size)
  17. #define MidFree(address) MyFree(address)
  18. #define BigAlloc(size) MyAlloc(size)
  19. #define BigFree(address) MyFree(address)
  20. #endif
  21. extern const ISzAlloc g_Alloc;
  22. extern const ISzAlloc g_BigAlloc;
  23. extern const ISzAlloc g_MidAlloc;
  24. extern const ISzAlloc g_AlignedAlloc;
  25. typedef struct
  26. {
  27. ISzAlloc vt;
  28. ISzAllocPtr baseAlloc;
  29. unsigned numAlignBits; /* ((1 << numAlignBits) >= sizeof(void *)) */
  30. size_t offset; /* (offset == (k * sizeof(void *)) && offset < (1 << numAlignBits) */
  31. } CAlignOffsetAlloc;
  32. void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p);
  33. EXTERN_C_END
  34. #endif