/**1* @file lv_mem.h2*3*/45#ifndef LV_MEM_H6#define LV_MEM_H78#ifdef __cplusplus9extern "C" {10#endif111213/*********************14* INCLUDES15*********************/16#ifdef LV_CONF_INCLUDE_SIMPLE17#include "lv_conf.h"18#else19#include "../../lv_conf.h"20#endif2122#include <stdint.h>23#include <stddef.h>24#include "lv_log.h"2526/*********************27* DEFINES28*********************/29// Check windows30#ifdef __WIN6431//# define LV_MEM_ENV6432#endif3334// Check GCC35#ifdef __GNUC__36# if defined(__x86_64__) || defined(__ppc64__)37//# define LV_MEM_ENV6438# endif39#endif4041/**********************42* TYPEDEFS43**********************/4445typedef struct46{47uint32_t total_size;48uint32_t free_cnt;49uint32_t free_size;50uint32_t free_biggest_size;51uint32_t used_cnt;52uint8_t used_pct;53uint8_t frag_pct;54} lv_mem_monitor_t;5556/**********************57* GLOBAL PROTOTYPES58**********************/596061/**62* Initiaize the dyn_mem module (work memory and other variables)63*/64void lv_mem_init(void);6566/**67* Allocate a memory dynamically68* @param size size of the memory to allocate in bytes69* @return pointer to the allocated memory70*/71void * lv_mem_alloc(uint32_t size);7273/**74* Free an allocated data75* @param data pointer to an allocated memory76*/77void lv_mem_free(const void * data);7879/**80* Reallocate a memory with a new size. The old content will be kept.81* @param data pointer to an allocated memory.82* Its content will be copied to the new memory block and freed83* @param new_size the desired new size in byte84* @return pointer to the new memory85*/86void * lv_mem_realloc(void * data_p, uint32_t new_size);8788/**89* Join the adjacent free memory blocks90*/91void lv_mem_defrag(void);9293/**94* Give information about the work memory of dynamic allocation95* @param mon_p pointer to a dm_mon_p variable,96* the result of the analysis will be stored here97*/98void lv_mem_monitor(lv_mem_monitor_t * mon_p);99100/**101* Give the size of an allocated memory102* @param data pointer to an allocated memory103* @return the size of data memory in bytes104*/105uint32_t lv_mem_get_size(const void * data);106107108/**********************109* MACROS110**********************/111112/**113* Halt on NULL pointer114* p pointer to a memory115*/116#if USE_LV_LOG == 0117# define lv_mem_assert(p) {if(p == NULL) while(1); }118#else119# define lv_mem_assert(p) {if(p == NULL) {LV_LOG_ERROR("Out of memory!"); while(1); }}120#endif121#ifdef __cplusplus122} /* extern "C" */123#endif124125#endif /*LV_MEM_H*/126127128129