Merge pull request #12715 from s-hadinger/berry_gc

Fix wrong gc count for instances
This commit is contained in:
Theo Arends 2021-07-21 13:21:06 +02:00 committed by GitHub
commit 9f0f08b1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -339,12 +339,19 @@ static void free_lstring(bvm *vm, bgcobject *obj)
}
}
static void free_instance(bvm *vm, bgcobject *obj)
{
binstance *o = cast_instance(obj);
int nvar = be_instance_member_count(o);
be_free(vm, obj, sizeof(binstance) + sizeof(bvalue) * (nvar - 1));
}
static void free_object(bvm *vm, bgcobject *obj)
{
switch (obj->type) {
case BE_STRING: free_lstring(vm, obj); break; /* long string */
case BE_CLASS: be_free(vm, obj, sizeof(bclass)); break;
case BE_INSTANCE: be_free(vm, obj, sizeof(binstance)); break;
case BE_INSTANCE: free_instance(vm, obj); break;
case BE_MAP: be_map_delete(vm, cast_map(obj)); break;
case BE_LIST: be_list_delete(vm, cast_list(obj)); break;
case BE_CLOSURE: free_closure(vm, obj); break;