[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 14/53] include/qapi: add g_autoptr support for qobject types
From: |
Paolo Bonzini |
Subject: |
[PULL 14/53] include/qapi: add g_autoptr support for qobject types |
Date: |
Tue, 19 Apr 2022 07:50:30 +0200 |
From: Marc-André Lureau <marcandre.lureau@redhat.com>
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>
---
include/qapi/qmp/qbool.h | 4 ++++
include/qapi/qmp/qdict.h | 4 ++++
include/qapi/qmp/qlist.h | 4 ++++
include/qapi/qmp/qnull.h | 4 ++++
include/qapi/qmp/qnum.h | 4 ++++
include/qapi/qmp/qstring.h | 4 ++++
qobject/qbool.c | 5 +++++
qobject/qdict.c | 5 +++++
qobject/qlist.c | 5 +++++
qobject/qnull.c | 5 +++++
qobject/qnum.c | 5 +++++
qobject/qstring.c | 5 +++++
12 files changed, 54 insertions(+)
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);
diff --git a/qobject/qbool.c b/qobject/qbool.c
index 16a600abb9..c7049c0c50 100644
--- a/qobject/qbool.c
+++ b/qobject/qbool.c
@@ -56,3 +56,8 @@ void qbool_destroy_obj(QObject *obj)
assert(obj != NULL);
g_free(qobject_to(QBool, obj));
}
+
+void qbool_unref(QBool *q)
+{
+ qobject_unref(q);
+}
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 0216ca7ac1..8faff230d3 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -442,3 +442,8 @@ void qdict_destroy_obj(QObject *obj)
g_free(qdict);
}
+
+void qdict_unref(QDict *q)
+{
+ qobject_unref(q);
+}
diff --git a/qobject/qlist.c b/qobject/qlist.c
index 60562a1f52..356ad946b0 100644
--- a/qobject/qlist.c
+++ b/qobject/qlist.c
@@ -182,3 +182,8 @@ void qlist_destroy_obj(QObject *obj)
g_free(qlist);
}
+
+void qlist_unref(QList *q)
+{
+ qobject_unref(q);
+}
diff --git a/qobject/qnull.c b/qobject/qnull.c
index b26b368219..445a5db7f3 100644
--- a/qobject/qnull.c
+++ b/qobject/qnull.c
@@ -29,3 +29,8 @@ bool qnull_is_equal(const QObject *x, const QObject *y)
{
return true;
}
+
+void qnull_unref(QNull *q)
+{
+ qobject_unref(q);
+}
diff --git a/qobject/qnum.c b/qobject/qnum.c
index 5dd66938dd..2bbeaedc7b 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -239,3 +239,8 @@ void qnum_destroy_obj(QObject *obj)
assert(obj != NULL);
g_free(qobject_to(QNum, obj));
}
+
+void qnum_unref(QNum *q)
+{
+ qobject_unref(q);
+}
diff --git a/qobject/qstring.c b/qobject/qstring.c
index b4613899b9..794f8c9357 100644
--- a/qobject/qstring.c
+++ b/qobject/qstring.c
@@ -100,3 +100,8 @@ void qstring_destroy_obj(QObject *obj)
g_free((char *)qs->string);
g_free(qs);
}
+
+void qstring_unref(QString *q)
+{
+ qobject_unref(q);
+}
--
2.35.1
- [PULL 08/53] meson: remove unneeded py3, (continued)
- [PULL 08/53] meson: remove unneeded py3, Paolo Bonzini, 2022/04/19
- [PULL 01/53] qapi, target/i386/sev: Add cpu0-id to query-sev-capabilities, Paolo Bonzini, 2022/04/19
- [PULL 11/53] Replace config-time define HOST_WORDS_BIGENDIAN, Paolo Bonzini, 2022/04/19
- [PULL 20/53] error-report: use error_printf() for program prefix, Paolo Bonzini, 2022/04/19
- [PULL 23/53] include: move qemu_pipe() to osdep.h, Paolo Bonzini, 2022/04/19
- [PULL 06/53] meson: use chardev_ss dependencies, Paolo Bonzini, 2022/04/19
- [PULL 07/53] meson: add util dependency for oslib-posix on freebsd, Paolo Bonzini, 2022/04/19
- [PULL 16/53] Replace qemu_real_host_page variables with inlined functions, Paolo Bonzini, 2022/04/19
- [PULL 14/53] include/qapi: add g_autoptr support for qobject types,
Paolo Bonzini <=
- [PULL 19/53] util: rename qemu-error.c to match its header name, Paolo Bonzini, 2022/04/19
- [PULL 21/53] include: move TFR to osdep.h, Paolo Bonzini, 2022/04/19
- [PULL 24/53] include: move coroutine IO functions to coroutine.h, Paolo Bonzini, 2022/04/19
- [PULL 27/53] include: move cpu_exec* declarations to cpu-common.h, Paolo Bonzini, 2022/04/19
- [PULL 37/53] build-sys: drop ntddscsi.h check, Paolo Bonzini, 2022/04/19
- [PULL 38/53] build-sys: simplify AF_VSOCK check, Paolo Bonzini, 2022/04/19
- [PULL 41/53] thread-posix: use monotonic clock for QemuCond and QemuSemaphore, Paolo Bonzini, 2022/04/19
- [PULL 40/53] thread-posix: remove the posix semaphore support, Paolo Bonzini, 2022/04/19
- [PULL 44/53] hyperv: SControl is optional to enable SynIc, Paolo Bonzini, 2022/04/19
- [PULL 52/53] target/i386: do not access beyond the low 128 bits of SSE registers, Paolo Bonzini, 2022/04/19