Re-org memory allocation interfaces, add --stack-size and --heap-size option (#193)

This commit is contained in:
wenyongh
2020-03-10 19:54:44 +08:00
committed by GitHub
parent 381859d530
commit 0fdd49ea31
110 changed files with 1264 additions and 2125 deletions

View File

@ -75,7 +75,7 @@ uint16 ntohs(uint16 value)
char *wa_strdup(const char *s)
{
char *s1 = NULL;
if (s && (s1 = wa_malloc(strlen(s) + 1)))
if (s && (s1 = WA_MALLOC(strlen(s) + 1)))
memcpy(s1, s, strlen(s) + 1);
return s1;
}

View File

@ -25,14 +25,14 @@ typedef int int32;
#define inline __inline
#endif
// all wasm-app<->native shared source files should use wa_malloc/wa_free.
// all wasm-app<->native shared source files should use WA_MALLOC/WA_FREE.
// they will be mapped to different implementations in each side
#ifndef wa_malloc
#define wa_malloc malloc
#ifndef WA_MALLOC
#define WA_MALLOC malloc
#endif
#ifndef wa_free
#define wa_free free
#ifndef WA_FREE
#define WA_FREE free
#endif
char *wa_strdup(const char *s);

View File

@ -107,7 +107,7 @@ timer_ctx_t create_wasm_timer_ctx(unsigned int module_id, int prealloc_num)
return NULL;
timer_ctx_node_t * node = (timer_ctx_node_t*)
bh_malloc(sizeof(timer_ctx_node_t));
wasm_runtime_malloc(sizeof(timer_ctx_node_t));
if (node == NULL) {
destroy_timer_ctx(ctx);
return NULL;
@ -131,7 +131,7 @@ void destroy_module_timer_ctx(unsigned int module_id)
if (timer_ctx_get_owner(elem->timer_ctx) == module_id) {
bh_list_remove(&g_timer_ctx_list, elem);
destroy_timer_ctx(elem->timer_ctx);
bh_free(elem);
wasm_runtime_free(elem);
break;
}