aboutsummaryrefslogtreecommitdiff
path: root/include/qapi
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2022-03-23 19:57:20 +0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-04-06 10:50:38 +0200
commitd709bbf3b17f43c91e82c3807a39f2c349d27934 (patch)
tree30e0ae475c7716d412000b7c2403092363a8afaf /include/qapi
parent7773e13fa729bbd2b106121b6c63b11a46c7d0c4 (diff)
include/qapi: add g_autoptr support for qobject types
Need wrappers for qobject_unref() calls, which is a macro. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220323155743.1585078-10-marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/qapi')
-rw-r--r--include/qapi/qmp/qbool.h4
-rw-r--r--include/qapi/qmp/qdict.h4
-rw-r--r--include/qapi/qmp/qlist.h4
-rw-r--r--include/qapi/qmp/qnull.h4
-rw-r--r--include/qapi/qmp/qnum.h4
-rw-r--r--include/qapi/qmp/qstring.h4
6 files changed, 24 insertions, 0 deletions
diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h
index 2f888d1057..0d09726939 100644
--- a/include/qapi/qmp/qbool.h
+++ b/include/qapi/qmp/qbool.h
@@ -21,6 +21,10 @@ struct QBool {
bool value;
};
+void qbool_unref(QBool *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QBool, qbool_unref)
+
QBool *qbool_from_bool(bool value);
bool qbool_get_bool(const QBool *qb);
diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h
index d5b5430e21..882d950bde 100644
--- a/include/qapi/qmp/qdict.h
+++ b/include/qapi/qmp/qdict.h
@@ -30,6 +30,10 @@ struct QDict {
QLIST_HEAD(,QDictEntry) table[QDICT_BUCKET_MAX];
};
+void qdict_unref(QDict *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QDict, qdict_unref)
+
/* Object API */
QDict *qdict_new(void);
const char *qdict_entry_key(const QDictEntry *entry);
diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h
index 06e98ad5f4..e4e985d435 100644
--- a/include/qapi/qmp/qlist.h
+++ b/include/qapi/qmp/qlist.h
@@ -26,6 +26,10 @@ struct QList {
QTAILQ_HEAD(,QListEntry) head;
};
+void qlist_unref(QList *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QList, qlist_unref)
+
#define qlist_append(qlist, obj) \
qlist_append_obj(qlist, QOBJECT(obj))
diff --git a/include/qapi/qmp/qnull.h b/include/qapi/qmp/qnull.h
index e84ecceedb..7feb7c7d83 100644
--- a/include/qapi/qmp/qnull.h
+++ b/include/qapi/qmp/qnull.h
@@ -26,4 +26,8 @@ static inline QNull *qnull(void)
return qobject_ref(&qnull_);
}
+void qnull_unref(QNull *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QNull, qnull_unref)
+
#endif /* QNULL_H */
diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h
index 7f84e20bfb..e86788dd2e 100644
--- a/include/qapi/qmp/qnum.h
+++ b/include/qapi/qmp/qnum.h
@@ -54,6 +54,10 @@ struct QNum {
} u;
};
+void qnum_unref(QNum *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QNum, qnum_unref)
+
QNum *qnum_from_int(int64_t value);
QNum *qnum_from_uint(uint64_t value);
QNum *qnum_from_double(double value);
diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h
index 1d8ba46936..318d815d6a 100644
--- a/include/qapi/qmp/qstring.h
+++ b/include/qapi/qmp/qstring.h
@@ -20,6 +20,10 @@ struct QString {
const char *string;
};
+void qstring_unref(QString *q);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(QString, qstring_unref)
+
QString *qstring_new(void);
QString *qstring_from_str(const char *str);
QString *qstring_from_substr(const char *str, size_t start, size_t end);