修改lvgl。cjson内存管理器
This commit is contained in:
1 parent
552a916705
commit
541738319d
11 files changed
+100
-26
No files matched your search
@@ -39,7 +39,7 @@
|
||||
*=========================*/
|
||||
|
||||
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#define LV_MEM_CUSTOM 1
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||
#define LV_MEM_SIZE (64U * 1024U) /*[bytes]*/
|
||||
@@ -54,9 +54,9 @@
|
||||
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||
#define LV_MEM_CUSTOM_ALLOC malloc
|
||||
#define LV_MEM_CUSTOM_FREE free
|
||||
#define LV_MEM_CUSTOM_REALLOC realloc
|
||||
#define LV_MEM_CUSTOM_ALLOC rt_memheap_alloc(&sdram_heap)
|
||||
#define LV_MEM_CUSTOM_FREE rt_memheap_free()
|
||||
#define LV_MEM_CUSTOM_REALLOC rt_memheap_realloc(&sdram_heap)
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
|
||||
|
||||
@@ -23,9 +23,15 @@
|
||||
#ifdef RT_USING_HEAP
|
||||
# define LV_MEM_CUSTOM 1
|
||||
# define LV_MEM_CUSTOM_INCLUDE LV_RTTHREAD_INCLUDE
|
||||
# define LV_MEM_CUSTOM_ALLOC rt_malloc
|
||||
# define LV_MEM_CUSTOM_FREE rt_free
|
||||
# define LV_MEM_CUSTOM_REALLOC rt_realloc
|
||||
//# define LV_MEM_CUSTOM_ALLOC rt_malloc
|
||||
//# define LV_MEM_CUSTOM_FREE rt_free
|
||||
//# define LV_MEM_CUSTOM_REALLOC rt_realloc
|
||||
|
||||
extern struct rt_memheap sdram_heap;
|
||||
#define LV_MEM_CUSTOM_ALLOC(x) rt_memheap_alloc(&sdram_heap,(rt_size_t)x)
|
||||
#define LV_MEM_CUSTOM_FREE rt_memheap_free
|
||||
#define LV_MEM_CUSTOM_REALLOC(x,y) rt_memheap_realloc(&sdram_heap,(x),(rt_size_t)(y))
|
||||
|
||||
#endif
|
||||
|
||||
/*====================
|
||||
|
||||
+3
-3
@@ -61,9 +61,9 @@
|
||||
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
#define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||
#define LV_MEM_CUSTOM_ALLOC malloc
|
||||
#define LV_MEM_CUSTOM_FREE free
|
||||
#define LV_MEM_CUSTOM_REALLOC realloc
|
||||
#define LV_MEM_CUSTOM_ALLOC rt_memheap_alloc(&sdram_heap)
|
||||
#define LV_MEM_CUSTOM_FREE rt_memheap_free()
|
||||
#define LV_MEM_CUSTOM_REALLOC rt_memheap_realloc(&sdram_heap)
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
|
||||
|
||||
Vendored
+23
-3
@@ -176,9 +176,29 @@ static void * CJSON_CDECL internal_realloc(void *pointer, size_t size)
|
||||
return realloc(pointer, size);
|
||||
}
|
||||
#elif defined(__RTTHREAD__)
|
||||
#define internal_malloc rt_malloc
|
||||
#define internal_free rt_free
|
||||
#define internal_realloc rt_realloc
|
||||
//#define internal_malloc rt_malloc
|
||||
//#define internal_free rt_free
|
||||
//#define internal_realloc rt_realloc
|
||||
|
||||
extern struct rt_memheap sdram_heap;
|
||||
|
||||
void *cjson_malloc(size_t size)
|
||||
{
|
||||
return rt_memheap_alloc(&sdram_heap, size);
|
||||
}
|
||||
void cjson_free(void *ptr)
|
||||
{
|
||||
if (ptr)
|
||||
rt_memheap_free(ptr);
|
||||
}
|
||||
void* cjson_realloc(void *ptr, size_t new_size) {
|
||||
return rt_memheap_realloc(&sdram_heap, ptr, new_size);
|
||||
}
|
||||
|
||||
#define internal_malloc cjson_malloc
|
||||
#define internal_free cjson_free
|
||||
#define internal_realloc cjson_realloc
|
||||
|
||||
#else
|
||||
#define internal_malloc malloc
|
||||
#define internal_free free
|
||||
|
||||
@@ -20727,13 +20727,13 @@ static malloc_zone_t* _sqliteZone_;
|
||||
** Use standard C library malloc and free on non-Apple systems.
|
||||
** Also used by rt-thread systems if SQLITE_WITHOUT_ZONEMALLOC is defined.
|
||||
*/
|
||||
extern struct rt_memheap sram_DTCMRAM;
|
||||
#define SQLITE_MALLOC(x) rt_memheap_alloc(&sram_DTCMRAM,(rt_size_t)x)
|
||||
/*extern struct rt_memheap sdram_heap;
|
||||
#define SQLITE_MALLOC(x) rt_memheap_alloc(&sdram_heap,(rt_size_t)x)
|
||||
#define SQLITE_FREE(x) rt_memheap_free(x)
|
||||
#define SQLITE_REALLOC(x,y) rt_memheap_realloc(&sram_DTCMRAM,(x),(rt_size_t)(y))
|
||||
//#define SQLITE_MALLOC(x) rt_malloc((rt_size_t)x)
|
||||
//#define SQLITE_FREE(x) rt_free(x)
|
||||
//#define SQLITE_REALLOC(x,y) rt_realloc((x),(rt_size_t)(y))
|
||||
#define SQLITE_REALLOC(x,y) rt_memheap_realloc(&sdram_heap,(x),(rt_size_t)(y))*/
|
||||
#define SQLITE_MALLOC(x) rt_malloc((rt_size_t)x)
|
||||
#define SQLITE_FREE(x) rt_free(x)
|
||||
#define SQLITE_REALLOC(x,y) rt_realloc((x),(rt_size_t)(y))
|
||||
|
||||
#if (!defined(SQLITE_WITHOUT_MSIZE)) \
|
||||
&& (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE))
|
||||
|
||||
Reference in new issue
Block a user