wasm_runtime_common.c: add assertion for BH_MALLOC/BH_FREE (#1139)

Add assertion for BH_MALLOC/BH_FREE in wasm_runtime_common.c,
when building runtime, the BH_MALLOC/BH_FREE macros should be
defined as wasm_runtime_malloc/wasm_runtime_free.
This commit is contained in:
YAMAMOTO Takashi 2022-05-06 14:47:56 +09:00 committed by GitHub
parent 16cfd4764d
commit 03f2153270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -29,6 +29,28 @@
#endif
#include "../common/wasm_c_api_internal.h"
/**
* For runtime build, BH_MALLOC/BH_FREE should be defined as
* wasm_runtime_malloc/wasm_runtime_free.
*/
#define CHECK(a) CHECK1(a)
#define CHECK1(a) SHOULD_BE_##a
#define SHOULD_BE_wasm_runtime_malloc 1
#if !CHECK(BH_MALLOC)
#error unexpected BH_MALLOC
#endif
#undef SHOULD_BE_wasm_runtime_malloc
#define SHOULD_BE_wasm_runtime_free 1
#if !CHECK(BH_FREE)
#error unexpected BH_FREE
#endif
#undef SHOULD_BE_wasm_runtime_free
#undef CHECK
#undef CHECK1
#if WASM_ENABLE_MULTI_MODULE != 0
/**
* A safety insurance to prevent