_malloc/stackAlloc #21468
-
Hi, My question is that the If this is the case, why do we have the responsibility to free the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Technically you can also free the pointer from Concretely, imagine we enter a function. It stores the current stack pointer as |
Beta Was this translation helpful? Give feedback.
Technically you can also free the pointer from
stackAlloc
(usingstackRestore
). However, the ABI used by clang and Emscripten for the wasm stack ensures that the stack is cleaned up when the parent unwinds anyhow.Concretely, imagine we enter a function. It stores the current stack pointer as
temp
. We can then do various small allocations in that function, and do not need to free anything there, because when the function exits it will dostackRestore(temp)
, which in effect frees all allocations in the middle.