Просмотр исходного кода

fix: lodepng应使用luat提供的heap方法

Wendal Chen 4 лет назад
Родитель
Сommit
d85640c2f4
2 измененных файлов с 8 добавлено и 3 удалено
  1. 7 3
      components/lvgl/exts/lv_png/lodepng.c
  2. 1 0
      components/lvgl/exts/lv_png/lodepng.h

+ 7 - 3
components/lvgl/exts/lv_png/lodepng.c

@@ -91,9 +91,13 @@ static void lodepng_free(void* ptr) {
 }
 #else /*LODEPNG_COMPILE_ALLOCATORS*/
 /* TODO: support giving additional void* payload to the custom allocators */
-void* lodepng_malloc(size_t size);
-void* lodepng_realloc(void* ptr, size_t new_size);
-void lodepng_free(void* ptr);
+// void* lodepng_malloc(size_t size);
+// void* lodepng_realloc(void* ptr, size_t new_size);
+// void lodepng_free(void* ptr);
+#include "luat_malloc.h"
+#define lodepng_malloc luat_heap_malloc
+#define lodepng_realloc luat_heap_realloc
+#define lodepng_free luat_heap_free
 #endif /*LODEPNG_COMPILE_ALLOCATORS*/
 
 /* convince the compiler to inline a function, for use when this measurably improves performance */

+ 1 - 0
components/lvgl/exts/lv_png/lodepng.h

@@ -29,6 +29,7 @@ freely, subject to the following restrictions:
 #include <string.h> /*for size_t*/
 
 #define LV_LVGL_H_INCLUDE_SIMPLE
+#define LODEPNG_NO_COMPILE_ALLOCATORS
 
 #ifndef LV_PNG_USE_LV_FILESYSTEM
 #define LV_PNG_USE_LV_FILESYSTEM 1