luat_mem.h 991 B

12345678910111213141516171819202122232425262728
  1. #ifndef LUAT_MEM_H
  2. #define LUAT_MEM_H
  3. #include "luat_malloc.h"
  4. typedef enum {
  5. LUAT_HEAP_AUTO,
  6. LUAT_HEAP_SRAM,
  7. LUAT_HEAP_PSRAM,
  8. } LUAT_HEAP_TYPE_E;
  9. void luat_heap_opt_init(LUAT_HEAP_TYPE_E type);
  10. void* luat_heap_opt_malloc(LUAT_HEAP_TYPE_E type,size_t len);
  11. void luat_heap_opt_free(LUAT_HEAP_TYPE_E type,void* ptr);
  12. void* luat_heap_opt_realloc(LUAT_HEAP_TYPE_E type,void* ptr, size_t len);
  13. void* luat_heap_opt_calloc(LUAT_HEAP_TYPE_E type,size_t count, size_t size);
  14. void* luat_heap_opt_zalloc(LUAT_HEAP_TYPE_E type,size_t size);
  15. void luat_meminfo_opt_sys(LUAT_HEAP_TYPE_E type,size_t* total, size_t* used, size_t* max_used);
  16. #define LUAT_MEM_MALLOC luat_heap_malloc
  17. #define LUAT_MEM_FREE luat_heap_free
  18. #define LUAT_MEM_REALLOC luat_heap_realloc
  19. #define LUAT_MEM_CALLOC luat_heap_calloc
  20. // 查询并输出内存使用情况到日志
  21. void luat_meminfo_query(LUAT_HEAP_TYPE_E type,size_t* total, size_t* used, size_t* max_used, int log_out);
  22. #endif