[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 13/13] qom: remove object_delete
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v4 13/13] qom: remove object_delete |
Date: |
Fri, 25 Jan 2013 14:12:39 +0100 |
This is now unused. Document the initial reference count of an object
and when it will be freed/finalized.
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qom/object.h | 27 ++++++++++-----------------
qom/object.c | 7 -------
2 files changed, 10 insertions(+), 24 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index 5e8e528..4dbcbe1 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -553,9 +553,9 @@ struct InterfaceClass
* object_new:
* @typename: The name of the type of the object to instantiate.
*
- * This function will initialize a new object using heap allocated memory.
This
- * function should be paired with object_delete() to free the resources
- * associated with the object.
+ * This function will initialize a new object using heap allocated memory.
+ * The returned object has a reference count of 1, and will be freed when
+ * the last reference is dropped.
*
* Returns: The newly allocated and instantiated object.
*/
@@ -565,30 +565,22 @@ Object *object_new(const char *typename);
* object_new_with_type:
* @type: The type of the object to instantiate.
*
- * This function will initialize a new object using heap allocated memory.
This
- * function should be paired with object_delete() to free the resources
- * associated with the object.
+ * This function will initialize a new object using heap allocated memory.
+ * The returned object has a reference count of 1, and will be freed when
+ * the last reference is dropped.
*
* Returns: The newly allocated and instantiated object.
*/
Object *object_new_with_type(Type type);
/**
- * object_delete:
- * @obj: The object to free.
- *
- * Finalize an object and then free the memory associated with it. This should
- * be paired with object_new() to free the resources associated with an object.
- */
-void object_delete(Object *obj);
-
-/**
* object_initialize_with_type:
* @obj: A pointer to the memory to be used for the object.
* @type: The type of the object to instantiate.
*
* This function will initialize an object. The memory for the object should
- * have already been allocated.
+ * have already been allocated. The returned object has a reference count of
1,
+ * and will be finalized when the last reference is dropped.
*/
void object_initialize_with_type(void *data, Type type);
@@ -598,7 +590,8 @@ void object_initialize_with_type(void *data, Type type);
* @typename: The name of the type of the object to instantiate.
*
* This function will initialize an object. The memory for the object should
- * have already been allocated.
+ * have already been allocated. The returned object has a reference count of
1,
+ * and will be finalized when the last reference is dropped.
*/
void object_initialize(void *obj, const char *typename);
diff --git a/qom/object.c b/qom/object.c
index 1a123da..aa89e21 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -417,13 +417,6 @@ Object *object_new(const char *typename)
return object_new_with_type(ti);
}
-void object_delete(Object *obj)
-{
- object_unparent(obj);
- g_assert(obj->ref == 1);
- object_unref(obj);
-}
-
Object *object_dynamic_cast(Object *obj, const char *typename)
{
if (obj && object_class_dynamic_cast(object_get_class(obj), typename)) {
--
1.8.1
- [Qemu-devel] [PATCH v4 04/13] qom: preserve object while unparenting it, (continued)
- [Qemu-devel] [PATCH v4 04/13] qom: preserve object while unparenting it, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 02/13] qdev: change first argument of qbus_create_inplace to void *, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 05/13] qom: document reference counting of link properties, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 08/13] qdev: move unrealization of devices from finalize to unparent, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 09/13] qdev: add reference for the bus while it is referred to by the DeviceState, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 11/13] qdev: drop extra references at creation time, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 12/13] cpu: do not use object_delete, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 10/13] qdev: inline object_delete into qbus_free/qdev_free, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 07/13] qdev: move deletion of children from finalize to unparent, Paolo Bonzini, 2013/01/25
- [Qemu-devel] [PATCH v4 13/13] qom: remove object_delete,
Paolo Bonzini <=