1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00
lvgl/lv_misc/lv_mem.h

106 lines
2.0 KiB
C
Raw Normal View History

2017-11-23 20:42:14 +01:00
/**
2017-11-23 21:28:36 +01:00
* @file lv_mem.h
2017-11-23 20:42:14 +01:00
*
*/
2017-11-23 21:28:36 +01:00
#ifndef LV_MEM_H
#define LV_MEM_H
2017-11-23 20:42:14 +01:00
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "misc_conf.h"
#include <stdint.h>
#include <stddef.h>
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
typedef struct
{
uint32_t cnt_free;
uint32_t cnt_used;
uint32_t size_free;
uint32_t size_total;
uint32_t size_free_big;
uint8_t pct_frag;
uint8_t pct_used;
}dm_mon_t;
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Initiaize the dyn_mem module (work memory and other variables)
*/
2017-11-23 21:28:36 +01:00
void lv_mem_init(void);
2017-11-23 20:42:14 +01:00
/**
* Allocate a memory dynamically
* @param size size of the memory to allocate in bytes
* @return pointer to the allocated memory
*/
2017-11-23 21:28:36 +01:00
void * lv_mem_alloc(uint32_t size);
2017-11-23 20:42:14 +01:00
/**
* Free an allocated data
* @param data pointer to an allocated memory
*/
2017-11-23 21:28:36 +01:00
void lv_mem_free(const void * data);
2017-11-23 20:42:14 +01:00
/**
* Reallocate a memory with a new size. The old content will be kept.
* @param data pointer to an allocated memory.
* Its content will be copied to the new memory block and freed
* @param new_size the desired new size in byte
* @return pointer to the new memory
*/
2017-11-23 21:28:36 +01:00
void * lv_mem_realloc(void * data_p, uint32_t new_size);
2017-11-23 20:42:14 +01:00
/**
* Join the adjacent free memory blocks
*/
2017-11-23 21:28:36 +01:00
void lv_mem_defrag(void);
2017-11-23 20:42:14 +01:00
/**
* Give information about the work memory of dynamic allocation
* @param mon_p pointer to a dm_mon_p variable,
* the result of the analysis will be stored here
*/
2017-11-23 21:28:36 +01:00
void lv_mem_monitor(dm_mon_t * mon_p);
2017-11-23 20:42:14 +01:00
/**
* Give the size of an allocated memory
* @param data pointer to an allocated memory
* @return the size of data memory in bytes
*/
uint32_t dm_get_size(void * data);
/**********************
* MACROS
**********************/
#define dm_assert(p) {if(p == NULL) {while(1);}}
#ifdef __cplusplus
} /* extern "C" */
#endif
2017-11-23 21:28:36 +01:00
#endif /*LV_MEM_H*/
2017-11-23 20:42:14 +01:00