mikroSDK Reference Manual
lv_mem.h
Go to the documentation of this file.
1
6#ifndef LV_MEM_H
7#define LV_MEM_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#include <stdint.h>
19#include <stddef.h>
20#include <string.h>
21
22#include "lv_types.h"
23
24/*********************
25 * DEFINES
26 *********************/
27
28/**********************
29 * TYPEDEFS
30 **********************/
31
35typedef struct {
36 uint32_t total_size;
37 uint32_t free_cnt;
38 uint32_t free_size;
39 uint32_t free_biggest_size;
40 uint32_t used_cnt;
41 uint32_t max_used;
42 uint8_t used_pct;
43 uint8_t frag_pct;
45
46typedef struct {
47 void * p;
48 uint16_t size;
49 uint8_t used : 1;
51
52typedef lv_mem_buf_t lv_mem_buf_arr_t[LV_MEM_BUF_MAX_NUM];
53
54/**********************
55 * GLOBAL PROTOTYPES
56 **********************/
57
61void lv_mem_init(void);
62
67void lv_mem_deinit(void);
68
74void * lv_mem_alloc(size_t size);
75
80void lv_mem_free(void * data);
81
89void * lv_mem_realloc(void * data_p, size_t new_size);
90
95lv_res_t lv_mem_test(void);
96
103
104
109void * lv_mem_buf_get(uint32_t size);
110
115void lv_mem_buf_release(void * p);
116
121
123
124#if LV_MEMCPY_MEMSET_STD
125
132static inline void * lv_memcpy(void * dst, const void * src, size_t len)
133{
134 return memcpy(dst, src, len);
135}
136
143static inline void * lv_memcpy_small(void * dst, const void * src, size_t len)
144{
145 return memcpy(dst, src, len);
146}
147
154static inline void lv_memset(void * dst, uint8_t v, size_t len)
155{
156 memset(dst, v, len);
157}
158
164static inline void lv_memset_00(void * dst, size_t len)
165{
166 memset(dst, 0x00, len);
167}
168
174static inline void lv_memset_ff(void * dst, size_t len)
175{
176 memset(dst, 0xFF, len);
177}
178
179#else
186LV_ATTRIBUTE_FAST_MEM void * lv_memcpy(void * dst, const void * src, size_t len);
187
194LV_ATTRIBUTE_FAST_MEM static inline void * lv_memcpy_small(void * dst, const void * src, size_t len)
195{
196 uint8_t * d8 = (uint8_t *)dst;
197 const uint8_t * s8 = (const uint8_t *)src;
198
199 while(len) {
200 *d8 = *s8;
201 d8++;
202 s8++;
203 len--;
204 }
205
206 return dst;
207}
208
215LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len);
216
222LV_ATTRIBUTE_FAST_MEM void lv_memset_00(void * dst, size_t len);
223
229LV_ATTRIBUTE_FAST_MEM void lv_memset_ff(void * dst, size_t len);
230
232
233#endif
234
235/**********************
236 * MACROS
237 **********************/
238
239#ifdef __cplusplus
240} /*extern "C"*/
241#endif
242
243#endif /*LV_MEM_H*/
void * lv_mem_alloc(size_t size)
void * lv_mem_buf_get(uint32_t size)
void * lv_mem_realloc(void *data_p, size_t new_size)
void lv_mem_monitor(lv_mem_monitor_t *mon_p)
void lv_mem_buf_free_all(void)
void lv_mem_buf_release(void *p)
lv_res_t lv_mem_test(void)
void lv_mem_init(void)
void lv_mem_deinit(void)
void lv_mem_free(void *data)
Definition lv_mem.h:46
Definition lv_mem.h:35
uint32_t free_size
Definition lv_mem.h:38
uint8_t frag_pct
Definition lv_mem.h:43
uint8_t used_pct
Definition lv_mem.h:42
uint32_t max_used
Definition lv_mem.h:41
uint32_t total_size
Definition lv_mem.h:36