Parcourir la source

fix: protobuf, 因为有free空指针的调用,在部分bsp会打印错误日志,虽然不影响使用

Wendal Chen il y a 8 mois
Parent
commit
bba9e63246

+ 7 - 0
components/serialization/protobuf/luat_lib_protobuf.c

@@ -2233,6 +2233,13 @@ LUALIB_API int luaopen_protobuf(lua_State *L) {
     return 1;
 }
 
+void luat_heap_free(void* ptr);
+void luat_heap_free_pb(void* ptr) {
+    if (ptr) {
+        luat_heap_free(ptr);
+    }
+}
+
 PB_NS_END
 
 /* cc: flags+='-O3 -ggdb -pedantic -std=c90 -Wall -Wextra --coverage'

+ 2 - 2
components/serialization/protobuf/pb.h

@@ -43,10 +43,10 @@
 #include <limits.h>
 
 void* luat_heap_malloc(size_t len);
-void  luat_heap_free(void* ptr);
+void  luat_heap_free_pb(void* ptr);
 
 #define os_malloc luat_heap_malloc
-#define os_free luat_heap_free
+#define os_free luat_heap_free_pb
 
 PB_NS_BEGIN