obj: use ref-counting in set objects

This commit is contained in:
2023-03-05 18:26:05 +00:00
parent d41ea0cd52
commit 8285506e58
2 changed files with 4 additions and 4 deletions

View File

@@ -90,8 +90,6 @@ void object_deref(object_t *obj)
} }
vm_cache_free(&obj->ob_type->ob_cache, obj); vm_cache_free(&obj->ob_type->ob_cache, obj);
spin_unlock_irqrestore(&obj->ob_lock, flags);
} }
void object_lock(object_t *obj, unsigned long *flags) void object_lock(object_t *obj, unsigned long *flags)

View File

@@ -20,7 +20,7 @@ static kern_status_t set_get_child_at(object_t *obj, size_t at, object_t **out)
size_t i = 0; size_t i = 0;
queue_foreach(object_t, child, &set->s_list, ob_list) { queue_foreach(object_t, child, &set->s_list, ob_list) {
if (i == at) { if (i == at) {
*out = child; *out = object_ref(child);
return KERN_OK; return KERN_OK;
} }
@@ -42,7 +42,7 @@ static kern_status_t set_get_child_named(object_t *obj, const char *name, object
} }
if (!strcmp(child_name, name)) { if (!strcmp(child_name, name)) {
*out = child; *out = object_ref(child);
return KERN_OK; return KERN_OK;
} }
} }
@@ -104,6 +104,7 @@ kern_status_t set_add_object(object_t *set_obj, object_t *obj)
} }
} }
object_ref(obj);
queue_push_back(&set->s_list, &obj->ob_list); queue_push_back(&set->s_list, &obj->ob_list);
return KERN_OK; return KERN_OK;
} }
@@ -116,6 +117,7 @@ kern_status_t set_remove_object(object_t *set_obj, object_t *obj)
struct set *set = object_data(set_obj); struct set *set = object_data(set_obj);
queue_delete(&set->s_list, &obj->ob_list); queue_delete(&set->s_list, &obj->ob_list);
object_deref(obj);
return KERN_OK; return KERN_OK;
} }