* [Qemu-devel] [PATCH] qom: Introduce object_property_remove()
@ 2014-01-07 1:32 Namhyung Kim
0 siblings, 0 replies; only message in thread
From: Namhyung Kim @ 2014-01-07 1:32 UTC (permalink / raw)
To: qemu-devel
As the object_property_del(), object_property_del_child() and
object_property_del_all() do similar job, factor out the common code
to a new object_property_remove().
It'll also remove unnecessary call to object_property_find() in case
of object_property_del_child() so that we can get rid of the unused
errp argument too.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
qom/object.c | 39 ++++++++++++++++++---------------------
1 file changed, 18 insertions(+), 21 deletions(-)
diff --git a/qom/object.c b/qom/object.c
index fc19cf6..a38cf72 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -347,30 +347,35 @@ static inline bool object_property_is_link(ObjectProperty *prop)
return strstart(prop->type, "link<", NULL);
}
+static void object_property_remove(Object *obj, ObjectProperty *prop)
+{
+ QTAILQ_REMOVE(&obj->properties, prop, node);
+
+ if (prop->release) {
+ prop->release(obj, prop->name, prop->opaque);
+ }
+
+ g_free(prop->name);
+ g_free(prop->type);
+ g_free(prop);
+}
+
static void object_property_del_all(Object *obj)
{
while (!QTAILQ_EMPTY(&obj->properties)) {
ObjectProperty *prop = QTAILQ_FIRST(&obj->properties);
- QTAILQ_REMOVE(&obj->properties, prop, node);
-
- if (prop->release) {
- prop->release(obj, prop->name, prop->opaque);
- }
-
- g_free(prop->name);
- g_free(prop->type);
- g_free(prop);
+ object_property_remove(obj, prop);
}
}
-static void object_property_del_child(Object *obj, Object *child, Error **errp)
+static void object_property_del_child(Object *obj, Object *child)
{
ObjectProperty *prop;
QTAILQ_FOREACH(prop, &obj->properties, node) {
if (object_property_is_child(prop) && prop->opaque == child) {
- object_property_del(obj, prop->name, errp);
+ object_property_remove(obj, prop);
break;
}
}
@@ -387,7 +392,7 @@ void object_unparent(Object *obj)
(obj->class->unparent)(obj);
}
if (obj->parent) {
- object_property_del_child(obj->parent, obj, NULL);
+ object_property_del_child(obj->parent, obj);
}
object_unref(obj);
}
@@ -763,15 +768,7 @@ void object_property_del(Object *obj, const char *name, Error **errp)
return;
}
- if (prop->release) {
- prop->release(obj, name, prop->opaque);
- }
-
- QTAILQ_REMOVE(&obj->properties, prop, node);
-
- g_free(prop->name);
- g_free(prop->type);
- g_free(prop);
+ object_property_remove(obj, prop);
}
void object_property_get(Object *obj, Visitor *v, const char *name,
--
1.7.11.7
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-01-07 1:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-07 1:32 [Qemu-devel] [PATCH] qom: Introduce object_property_remove() Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).