Browse Source

change: 把内存释放的判断改到malloc里,就不必修改lua vm的代码了, 非常nice

Wendal Chen 4 năm trước cách đây
mục cha
commit
be1b45b500
2 tập tin đã thay đổi với 20 bổ sung6 xóa
  1. 0 6
      app/port/luat_fs_air101.c
  2. 20 0
      app/port/luat_malloc_air101.c

+ 0 - 6
app/port/luat_fs_air101.c

@@ -23,12 +23,6 @@ uint32_t luadb_size_kb;
 uint32_t lfs_addr;
 uint32_t lfs_size_kb;
 
-const uint32_t luat_rom_addr_start = 0x8010000;
-#ifdef AIR103
-const uint32_t luat_rom_addr_end   = 0x80FFFFF;
-#else
-const uint32_t luat_rom_addr_end   = 0x81FFFFF;
-#endif
 
 #ifndef FLASH_FS_REGION_SIZE
 #define FLASH_FS_REGION_SIZE 112

+ 20 - 0
app/port/luat_malloc_air101.c

@@ -11,6 +11,14 @@
 #include "luat_log.h"
 #include "wm_mem.h"
 
+
+const uint32_t luat_rom_addr_start = 0x8010000;
+#ifdef AIR103
+const uint32_t luat_rom_addr_end   = 0x80FFFFF;
+#else
+const uint32_t luat_rom_addr_end   = 0x81FFFFF;
+#endif
+
 //------------------------------------------------
 //  管理系统内存
 
@@ -64,7 +72,19 @@ void* __attribute__((section (".ram_run"))) luat_heap_alloc(void *ud, void *ptr,
     	}
         return ptmp;
     }
+#if 0
+    uint32_t ptrv = (uint32_t)ptr;
+    if (ptrv != 0) {
+        if (ptrv >= luat_rom_addr_start && ptrv <= luat_rom_addr_end) {
+            // nop 无需释放
+        }
+        else {
+            brel(ptr);
+        }
+    }
+#else
     brel(ptr);
+#endif
     return NULL;
 }