Skip to content

Commit 74dbafc

Browse files
authored
Export API wasm_runtime_enlarge_memory (#3569)
Export API wasm_runtime_enlarge_memory to support memory growth.
1 parent 6754b62 commit 74dbafc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

core/iwasm/common/wasm_memory.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,26 @@ wasm_enlarge_memory_internal(WASMModuleInstance *module, uint32 inc_page_count)
919919
return ret;
920920
}
921921

922+
bool
923+
wasm_runtime_enlarge_memory(WASMModuleInstanceCommon *module_inst,
924+
uint32_t inc_page_count)
925+
{
926+
#if WASM_ENABLE_AOT != 0
927+
if (module_inst->module_type == Wasm_Module_AoT) {
928+
return aot_enlarge_memory((AOTModuleInstance *)module_inst,
929+
inc_page_count);
930+
}
931+
#endif
932+
#if WASM_ENABLE_INTERP != 0
933+
if (module_inst->module_type == Wasm_Module_Bytecode) {
934+
return wasm_enlarge_memory((WASMModuleInstance *)module_inst,
935+
inc_page_count);
936+
}
937+
#endif
938+
939+
return false;
940+
}
941+
922942
void
923943
wasm_runtime_set_enlarge_mem_error_callback(
924944
const enlarge_memory_error_callback_t callback, void *user_data)

core/iwasm/include/wasm_export.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,10 @@ WASM_RUNTIME_API_EXTERN bool
18421842
wasm_runtime_is_import_global_linked(const char *module_name,
18431843
const char *global_name);
18441844

1845+
WASM_RUNTIME_API_EXTERN bool
1846+
wasm_runtime_enlarge_memory(wasm_module_inst_t module_inst,
1847+
uint32_t inc_page_count);
1848+
18451849
typedef enum {
18461850
INTERNAL_ERROR,
18471851
MAX_SIZE_REACHED,

0 commit comments

Comments
 (0)