py: Properly free string parse-node; add assertion to gc_free.

This commit is contained in:
Damien George 2014-10-23 14:13:05 +01:00
parent dd4f4530ab
commit e7bb0443cd
2 changed files with 15 additions and 11 deletions

View File

@ -484,7 +484,11 @@ void gc_free(void *ptr_in) {
#if EXTENSIVE_HEAP_PROFILING
gc_dump_alloc_table();
#endif
} else {
assert(!"bad free");
}
} else if (ptr_in != NULL) {
assert(!"bad free");
}
}

View File

@ -180,17 +180,17 @@ void mp_parse_node_free(mp_parse_node_t pn) {
mp_uint_t rule_id = MP_PARSE_NODE_STRUCT_KIND(pns);
if (rule_id == RULE_string) {
m_del(char, (char*)pns->nodes[0], (mp_uint_t)pns->nodes[1]);
return;
}
bool adjust = ADD_BLANK_NODE(rule_id);
if (adjust) {
n--;
}
for (mp_uint_t i = 0; i < n; i++) {
mp_parse_node_free(pns->nodes[i]);
}
if (adjust) {
n++;
} else {
bool adjust = ADD_BLANK_NODE(rule_id);
if (adjust) {
n--;
}
for (mp_uint_t i = 0; i < n; i++) {
mp_parse_node_free(pns->nodes[i]);
}
if (adjust) {
n++;
}
}
m_del_var(mp_parse_node_struct_t, mp_parse_node_t, n, pns);
}