|
@@ -464,7 +464,37 @@ moudle_destroyer(uint8 *buffer, uint32 size)
|
|
|
|
|
|
|
|
#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
|
|
#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
|
|
|
static char global_heap_buf[WASM_GLOBAL_HEAP_SIZE] = { 0 };
|
|
static char global_heap_buf[WASM_GLOBAL_HEAP_SIZE] = { 0 };
|
|
|
|
|
+#else
|
|
|
|
|
+static void *
|
|
|
|
|
+malloc_func(
|
|
|
|
|
+#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
|
|
|
|
+ void *user_data,
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+ unsigned int size)
|
|
|
|
|
+{
|
|
|
|
|
+ return malloc(size);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void *
|
|
|
|
|
+realloc_func(
|
|
|
|
|
+#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
|
|
|
|
+ void *user_data,
|
|
|
|
|
+#endif
|
|
|
|
|
+ void *ptr, unsigned int size)
|
|
|
|
|
+{
|
|
|
|
|
+ return realloc(ptr, size);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void
|
|
|
|
|
+free_func(
|
|
|
|
|
+#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
|
|
|
|
+ void *user_data,
|
|
|
|
|
+#endif
|
|
|
|
|
+ void *ptr)
|
|
|
|
|
+{
|
|
|
|
|
+ free(ptr);
|
|
|
|
|
+}
|
|
|
|
|
+#endif /* end of WASM_ENABLE_GLOBAL_HEAP_POOL */
|
|
|
|
|
|
|
|
#if WASM_ENABLE_STATIC_PGO != 0
|
|
#if WASM_ENABLE_STATIC_PGO != 0
|
|
|
static void
|
|
static void
|
|
@@ -861,9 +891,13 @@ main(int argc, char *argv[])
|
|
|
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
|
|
init_args.mem_alloc_option.pool.heap_size = sizeof(global_heap_buf);
|
|
|
#else
|
|
#else
|
|
|
init_args.mem_alloc_type = Alloc_With_Allocator;
|
|
init_args.mem_alloc_type = Alloc_With_Allocator;
|
|
|
- init_args.mem_alloc_option.allocator.malloc_func = malloc;
|
|
|
|
|
- init_args.mem_alloc_option.allocator.realloc_func = realloc;
|
|
|
|
|
- init_args.mem_alloc_option.allocator.free_func = free;
|
|
|
|
|
|
|
+#if WASM_MEM_ALLOC_WITH_USER_DATA != 0
|
|
|
|
|
+ /* Set user data for the allocator is needed */
|
|
|
|
|
+ /* init_args.mem_alloc_option.allocator.user_data = user_data; */
|
|
|
|
|
+#endif
|
|
|
|
|
+ init_args.mem_alloc_option.allocator.malloc_func = malloc_func;
|
|
|
|
|
+ init_args.mem_alloc_option.allocator.realloc_func = realloc_func;
|
|
|
|
|
+ init_args.mem_alloc_option.allocator.free_func = free_func;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
#if WASM_ENABLE_FAST_JIT != 0
|
|
#if WASM_ENABLE_FAST_JIT != 0
|