Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't leak implementation into headers. #75

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions include/wasm.hh
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,8 @@ class vec {
size_t size_;
std::unique_ptr<T[]> data_;

#ifdef DEBUG
void make_data();
void free_data();
#else
void make_data() {}
void free_data() {}
#endif

vec(size_t size) : vec(size, size ? new(std::nothrow) T[size] : nullptr) {
make_data();
Expand Down
10 changes: 8 additions & 2 deletions src/wasm-v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,14 @@ Stats stats;
if (data_) stats.free(Stats::STAT, data_.get(), Stats::VEC); \
}

#else

#define DEFINE_VEC(type, STAT) \
template<> void vec<type>::make_data() {} \
template<> void vec<type>::free_data() {}

#endif // #ifdef DEBUG

DEFINE_VEC(byte_t, BYTE)
DEFINE_VEC(Frame*, FRAME)
DEFINE_VEC(ValType*, VALTYPE)
Expand All @@ -231,8 +239,6 @@ DEFINE_VEC(Memory*, MEMORY)
DEFINE_VEC(Extern*, EXTERN)
DEFINE_VEC(Val, VAL)

#endif // #ifdef DEBUG


///////////////////////////////////////////////////////////////////////////////
// Runtime Environment
Expand Down