Open Hywan opened 3 years ago
Oh, ouch. I see there is an inconsistency there. Unfortunately, I think this is the wrong fix. These constructors don't take ownership of the string in the implementation, nor should they -- you wouldn't be able to create a name form a string literal, for example.
It's the definition of WASM_DECLARE_VEC
that is wrong here. The own
on wasm_byte_vec_new
doesn't actually make sense when ptr_or_none
is empty.
I think the right fix would be to move the own
from the macro's definition to its invocations, passing own*
for ptr_or_none
where it currently passes just *
. Or to split the macro in three, analogous to the implementation in wasm-c.cc.
wasm_name_new
is an alias towasm_byte_vec_new
, which owns theptr_or_none
argument, which is in this cases
.This patch adds the
own
market towasm_name_new_from_string
andwasm_name_new_from_string_nt
.