Skip to content

Commit 70b6a0c

Browse files
authored
feat: fallback to malloc if proxy_on_memory_allocate not found (#17)
1 parent 0985259 commit 70b6a0c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/vm/wasmtime.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,12 @@ ngx_wasm_wasmtime_malloc(ngx_log_t *log, int32_t size)
315315
found = wasmtime_instance_export_get(cur_plugin->context, &cur_plugin->instance,
316316
"proxy_on_memory_allocate", 24, &func);
317317
if (!found) {
318-
ngx_log_error(NGX_LOG_ERR, log, 0, "can't find malloc in the WASM plugin");
319-
return 0;
318+
found = wasmtime_instance_export_get(cur_plugin->context, &cur_plugin->instance,
319+
"malloc", 6, &func);
320+
if (!found) {
321+
ngx_log_error(NGX_LOG_ERR, log, 0, "can't find malloc in the WASM plugin");
322+
return 0;
323+
}
320324
}
321325

322326
params[0].kind = WASMTIME_I32;

0 commit comments

Comments
 (0)