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

Use 64-bit wasm_runtime_enlarge_memory() increment (#3573)

ps.
https://github.com/bytecodealliance/wasm-micro-runtime/pull/3569#discussion_r1654398315
Benbuck Nason 1 год назад
Родитель
Сommit
837ff63662
2 измененных файлов с 14 добавлено и 2 удалено
  1. 5 1
      core/iwasm/common/wasm_memory.c
  2. 9 1
      core/iwasm/include/wasm_export.h

+ 5 - 1
core/iwasm/common/wasm_memory.c

@@ -921,8 +921,12 @@ return_func:
 
 bool
 wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module_inst,
-                            uint32_t inc_page_count)
+                            uint64 inc_page_count)
 {
+    if (inc_page_count > UINT32_MAX) {
+        return false;
+    }
+
 #if WASM_ENABLE_AOT != 0
     if (module_inst->module_type == Wasm_Module_AoT) {
         return aot_enlarge_memory((AOTModuleInstance *)module_inst,

+ 9 - 1
core/iwasm/include/wasm_export.h

@@ -1842,9 +1842,17 @@ WASM_RUNTIME_API_EXTERN bool
 wasm_runtime_is_import_global_linked(const char *module_name,
                                      const char *global_name);
 
+/**
+ * Enlarge the memory region for a module instance
+ *
+ * @param module_inst the module instance
+ * @param inc_page_count the number of pages to add
+ *
+ * @return true if success, false otherwise
+ */
 WASM_RUNTIME_API_EXTERN bool
 wasm_runtime_enlarge_memory(wasm_module_inst_t module_inst,
-                            uint32_t inc_page_count);
+                            uint64_t inc_page_count);
 
 typedef enum {
     INTERNAL_ERROR,