Memory.h 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. namespace il2cpp
  4. {
  5. namespace utils
  6. {
  7. struct LIBIL2CPP_CODEGEN_API Memory
  8. {
  9. static void SetMemoryCallbacks(Il2CppMemoryCallbacks* callbacks);
  10. static void* Malloc(size_t size);
  11. static void* AlignedMalloc(size_t size, size_t alignment);
  12. static void Free(void* memory);
  13. static void AlignedFree(void* memory);
  14. static void* Calloc(size_t count, size_t size);
  15. static void* Realloc(void* memory, size_t newSize);
  16. static void* AlignedRealloc(void* memory, size_t newSize, size_t alignment);
  17. };
  18. } /* namespace utils */
  19. } /* namespace il2cpp */
  20. #define IL2CPP_MALLOC(size) il2cpp::utils::Memory::Malloc(size)
  21. #define IL2CPP_MALLOC_ALIGNED(size, alignment) il2cpp::utils::Memory::AlignedMalloc(size, alignment)
  22. #define IL2CPP_MALLOC_ZERO(size) il2cpp::utils::Memory::Calloc(1,size)
  23. #define IL2CPP_FREE(memory) il2cpp::utils::Memory::Free(memory)
  24. #define IL2CPP_FREE_ALIGNED(memory) il2cpp::utils::Memory::AlignedFree(memory)
  25. #define IL2CPP_CALLOC(count, size) il2cpp::utils::Memory::Calloc(count,size)
  26. #define IL2CPP_REALLOC(memory, newSize) il2cpp::utils::Memory::Realloc(memory,newSize)
  27. #define IL2CPP_REALLOC_ALIGNED(memory, newSize, alignment) il2cpp::utils::Memory::AlignedRealloc(memory, newSize, alignment)