*fixed a class gc bug.

This commit is contained in:
paladin-t 2015-12-21 15:51:01 +08:00
parent 5195a472ad
commit 6ba1d3cb54
2 changed files with 6 additions and 2 deletions

View File

@ -1,3 +1,6 @@
Dec. 21 2015
Fixed a class GC bug
Dec. 19 2015 Dec. 19 2015
Improved error handling when defining a class in C Improved error handling when defining a class in C

View File

@ -4482,10 +4482,11 @@ int _gc_destroy_garbage(void* data, void* extra) {
instance = (_class_t*)data; instance = (_class_t*)data;
_HT_FOREACH(instance->scope->var_dict, _do_nothing_on_object, _gc_destroy_garbage_in_class, gc); _HT_FOREACH(instance->scope->var_dict, _do_nothing_on_object, _gc_destroy_garbage_in_class, gc);
_ht_clear(instance->scope->var_dict); _ht_clear(instance->scope->var_dict);
_ls_clear(instance->meta_list);
break; break;
#endif /* MB_ENABLE_CLASS */ #endif /* MB_ENABLE_CLASS */
default: default: /* Do nothing */
break; break;
} }
if(ref->count) { if(ref->count) {
@ -5483,7 +5484,6 @@ void _unref_class(_ref_t* ref, void* data) {
void _destroy_class(_class_t* c) { void _destroy_class(_class_t* c) {
/* Destroy a class instance */ /* Destroy a class instance */
safe_free(c->name);
if(c->meta_list) { if(c->meta_list) {
_unlink_meta_class(c->ref.s, c); _unlink_meta_class(c->ref.s, c);
_ls_destroy(c->meta_list); _ls_destroy(c->meta_list);
@ -5494,6 +5494,7 @@ void _destroy_class(_class_t* c) {
} }
safe_free(c->scope); safe_free(c->scope);
_destroy_ref(&c->ref); _destroy_ref(&c->ref);
safe_free(c->name);
safe_free(c); safe_free(c);
} }