Add comments on trailing uint8[1] members in the "Common" structures (#1189)

Add comments to avoid abusing these members to store extra data.
This commit is contained in:
YAMAMOTO Takashi 2022-05-26 12:53:50 +09:00 committed by GitHub
parent 3fd763a95c
commit 3168ba8dcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -303,6 +303,11 @@ typedef struct WASMModuleCommon {
Wasm_Module_AoT, and this structure should be treated as Wasm_Module_AoT, and this structure should be treated as
AOTModule structure. */ AOTModule structure. */
uint32 module_type; uint32 module_type;
/* The following uint8[1] member is a dummy just to indicate
some module_type dependent members follow.
Typically it should be accessed by casting to the corresponding
actual module_type dependent structure, not via this member. */
uint8 module_data[1]; uint8 module_data[1];
} WASMModuleCommon; } WASMModuleCommon;
@ -314,6 +319,11 @@ typedef struct WASMModuleInstanceCommon {
Wasm_Module_AoT, and this structure should be treated as Wasm_Module_AoT, and this structure should be treated as
AOTModuleInstance structure. */ AOTModuleInstance structure. */
uint32 module_type; uint32 module_type;
/* The following uint8[1] member is a dummy just to indicate
some module_type dependent members follow.
Typically it should be accessed by casting to the corresponding
actual module_type dependent structure, not via this member. */
uint8 module_inst_data[1]; uint8 module_inst_data[1];
} WASMModuleInstanceCommon; } WASMModuleInstanceCommon;
@ -377,6 +387,11 @@ typedef struct WASMRegisteredModule {
typedef struct WASMMemoryInstanceCommon { typedef struct WASMMemoryInstanceCommon {
uint32 module_type; uint32 module_type;
/* The following uint8[1] member is a dummy just to indicate
some module_type dependent members follow.
Typically it should be accessed by casting to the corresponding
actual module_type dependent structure, not via this member. */
uint8 memory_inst_data[1]; uint8 memory_inst_data[1];
} WASMMemoryInstanceCommon; } WASMMemoryInstanceCommon;