move the owner tag inside

master
Daniel Kolesa 2021-03-25 01:55:47 +01:00
parent 468c3a07d4
commit c854e9d189
3 changed files with 5 additions and 8 deletions

View File

@ -560,7 +560,6 @@ struct LIBCUBESCRIPT_EXPORT state {
void swap(state &s) {
std::swap(p_tstate, s.p_tstate);
std::swap(identflags, s.identflags);
std::swap(p_owner, s.p_owner);
}
state new_thread();
@ -733,8 +732,6 @@ private:
ident *add_ident(ident *id, ident_impl *impl);
void *alloc(void *ptr, size_t olds, size_t news);
bool p_owner = false;
};
struct stack_state_node {

View File

@ -71,7 +71,7 @@ state::state(alloc_func func, void *data) {
p_tstate->pstate = this;
p_tstate->istate = statep;
p_owner = true;
p_tstate->owner = true;
for (int i = 0; i < MAX_ARGUMENTS; ++i) {
char buf[32];
@ -188,7 +188,7 @@ LIBCUBESCRIPT_EXPORT state::~state() {
}
LIBCUBESCRIPT_EXPORT void state::destroy() {
if (!p_tstate || !p_owner) {
if (!p_tstate || !p_tstate->owner) {
return;
}
auto *sp = p_tstate->istate;
@ -205,9 +205,7 @@ LIBCUBESCRIPT_EXPORT void state::destroy() {
sp->destroy(sp);
}
state::state(internal_state *s):
p_owner{false}
{
state::state(internal_state *s) {
p_tstate = s->create<thread_state>(s);
p_tstate->istate = s;
}

View File

@ -29,6 +29,8 @@ struct thread_state {
hook_func call_hook{};
/* loop nesting level */
int loop_level = 0;
/* whether we own the internal state (i.e. not a side thread */
bool owner = false;
thread_state(internal_state *cs);