From: Marc-André Lureau <marcandre.lur...@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> [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