瀏覽代碼

object: return self in object_ref()

This allow for simpler assignment with ref: foo = object_ref(bar)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200110153039.1379601-19-marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Marc-André Lureau 5 年之前
父節點
當前提交
b77ade9bb3
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 2 1
      include/qom/object.h
  2. 3 2
      qom/object.c

+ 2 - 1
include/qom/object.h

@@ -1005,8 +1005,9 @@ GSList *object_class_get_list_sorted(const char *implements_type,
  *
  *
  * Increase the reference count of a object.  A object cannot be freed as long
  * Increase the reference count of a object.  A object cannot be freed as long
  * as its reference count is greater than zero.
  * as its reference count is greater than zero.
+ * Returns: @obj
  */
  */
-void object_ref(Object *obj);
+Object *object_ref(Object *obj);
 
 
 /**
 /**
  * object_unref:
  * object_unref:

+ 3 - 2
qom/object.c

@@ -1107,12 +1107,13 @@ GSList *object_class_get_list_sorted(const char *implements_type,
                         object_class_cmp);
                         object_class_cmp);
 }
 }
 
 
-void object_ref(Object *obj)
+Object *object_ref(Object *obj)
 {
 {
     if (!obj) {
     if (!obj) {
-        return;
+        return NULL;
     }
     }
     atomic_inc(&obj->ref);
     atomic_inc(&obj->ref);
+    return obj;
 }
 }
 
 
 void object_unref(Object *obj)
 void object_unref(Object *obj)