[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH 32/88] QObject: use g_new() family of functions
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-trivial] [PATCH 32/88] QObject: use g_new() family of functions |
Date: |
Fri, 6 Oct 2017 20:49:27 -0300 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
[PMD: added qbool.c, qdict.c, qlist.c, qstring.c and tests/]
---
qobject/json-parser.c | 2 +-
qobject/qbool.c | 2 +-
qobject/qdict.c | 4 ++--
qobject/qlist.c | 4 ++--
qobject/qstring.c | 2 +-
tests/test-qobject-output-visitor.c | 4 ++--
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 724ca240e4..37dda9bc3f 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -247,7 +247,7 @@ static JSONParserContext *parser_context_new(GQueue *tokens)
return NULL;
}
- ctxt = g_malloc0(sizeof(JSONParserContext));
+ ctxt = g_new0(JSONParserContext, 1);
ctxt->buf = tokens;
return ctxt;
diff --git a/qobject/qbool.c b/qobject/qbool.c
index 0606bbd2a3..5ad7f6d98f 100644
--- a/qobject/qbool.c
+++ b/qobject/qbool.c
@@ -25,7 +25,7 @@ QBool *qbool_from_bool(bool value)
{
QBool *qb;
- qb = g_malloc(sizeof(*qb));
+ qb = g_new(QBool, 1);
qobject_init(QOBJECT(qb), QTYPE_QBOOL);
qb->value = value;
diff --git a/qobject/qdict.c b/qobject/qdict.c
index 576018e531..857e71c7a1 100644
--- a/qobject/qdict.c
+++ b/qobject/qdict.c
@@ -30,7 +30,7 @@ QDict *qdict_new(void)
{
QDict *qdict;
- qdict = g_malloc0(sizeof(*qdict));
+ qdict = g_new0(QDict, 1);
qobject_init(QOBJECT(qdict), QTYPE_QDICT);
return qdict;
@@ -70,7 +70,7 @@ static QDictEntry *alloc_entry(const char *key, QObject
*value)
{
QDictEntry *entry;
- entry = g_malloc0(sizeof(*entry));
+ entry = g_new0(QDictEntry, 1);
entry->key = g_strdup(key);
entry->value = value;
diff --git a/qobject/qlist.c b/qobject/qlist.c
index 86b60cb88c..8afc594d0d 100644
--- a/qobject/qlist.c
+++ b/qobject/qlist.c
@@ -25,7 +25,7 @@ QList *qlist_new(void)
{
QList *qlist;
- qlist = g_malloc(sizeof(*qlist));
+ qlist = g_new(QList, 1);
qobject_init(QOBJECT(qlist), QTYPE_QLIST);
QTAILQ_INIT(&qlist->head);
@@ -58,7 +58,7 @@ void qlist_append_obj(QList *qlist, QObject *value)
{
QListEntry *entry;
- entry = g_malloc(sizeof(*entry));
+ entry = g_new(QListEntry, 1);
entry->value = value;
QTAILQ_INSERT_TAIL(&qlist->head, entry, next);
diff --git a/qobject/qstring.c b/qobject/qstring.c
index 5da7b5f37c..806c0306a2 100644
--- a/qobject/qstring.c
+++ b/qobject/qstring.c
@@ -42,7 +42,7 @@ QString *qstring_from_substr(const char *str, int start, int
end)
{
QString *qstring;
- qstring = g_malloc(sizeof(*qstring));
+ qstring = g_new(QString, 1);
qobject_init(QOBJECT(qstring), QTYPE_QSTRING);
qstring->length = end - start + 1;
diff --git a/tests/test-qobject-output-visitor.c
b/tests/test-qobject-output-visitor.c
index d375100a52..d0a66a5dca 100644
--- a/tests/test-qobject-output-visitor.c
+++ b/tests/test-qobject-output-visitor.c
@@ -182,7 +182,7 @@ static void
test_visitor_out_struct_nested(TestOutputVisitorData *data,
const char *strings[] = { "forty two", "forty three", "forty four",
"forty five" };
- ud2 = g_malloc0(sizeof(*ud2));
+ ud2 = g_new0(UserDefTwo, 1);
ud2->string0 = g_strdup(strings[0]);
ud2->dict1 = g_malloc0(sizeof(*ud2->dict1));
@@ -372,7 +372,7 @@ static void
test_visitor_out_union_flat(TestOutputVisitorData *data,
{
QDict *qdict;
- UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));
+ UserDefFlatUnion *tmp = g_new0(UserDefFlatUnion, 1);
tmp->enum1 = ENUM_ONE_VALUE1;
tmp->string = g_strdup("str");
tmp->integer = 41;
--
2.14.2
- [Qemu-trivial] [PATCH 24/88] MIPS: use g_new() family of functions, (continued)
- [Qemu-trivial] [PATCH 24/88] MIPS: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 25/88] OpenRISC: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 26/88] S390: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 28/88] disas: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 27/88] SH4: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 29/88] SPARC: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 30/88] QEMU Guest Agent: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 32/88] QObject: use g_new() family of functions,
Philippe Mathieu-Daudé <=
- [Qemu-trivial] [PATCH 31/88] QMP: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 33/88] qom: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 34/88] qapi: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 35/88] Record/replay: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 36/88] SLIRP: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06