[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH 16/88] Main loop: use g_new() family of functions
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-trivial] [PATCH 16/88] Main loop: use g_new() family of functions |
Date: |
Fri, 6 Oct 2017 20:49:11 -0300 |
From: Marc-André Lureau <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
[PMD: more uses in vl.c (fixed const char * cast),
squashed cpus-common and changes in util/qemu-timer]
---
include/qemu/timer.h | 2 +-
cpus-common.c | 4 ++--
util/main-loop.c | 2 +-
util/qemu-timer.c | 2 +-
vl.c | 12 ++++++------
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 1b518bca30..dfc028259c 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -518,7 +518,7 @@ static inline QEMUTimer *timer_new_tl(QEMUTimerList
*timer_list,
QEMUTimerCB *cb,
void *opaque)
{
- QEMUTimer *ts = g_malloc0(sizeof(QEMUTimer));
+ QEMUTimer *ts = g_new0(QEMUTimer, 1);
timer_init_tl(ts, timer_list, scale, cb, opaque);
return ts;
}
diff --git a/cpus-common.c b/cpus-common.c
index 59f751ecf9..e613cc33ef 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -158,7 +158,7 @@ void async_run_on_cpu(CPUState *cpu, run_on_cpu_func func,
run_on_cpu_data data)
{
struct qemu_work_item *wi;
- wi = g_malloc0(sizeof(struct qemu_work_item));
+ wi = g_new0(struct qemu_work_item, 1);
wi->func = func;
wi->data = data;
wi->free = true;
@@ -301,7 +301,7 @@ void async_safe_run_on_cpu(CPUState *cpu, run_on_cpu_func
func,
{
struct qemu_work_item *wi;
- wi = g_malloc0(sizeof(struct qemu_work_item));
+ wi = g_new0(struct qemu_work_item, 1);
wi->func = func;
wi->data = data;
wi->free = true;
diff --git a/util/main-loop.c b/util/main-loop.c
index 7558eb5f53..ef784bcda0 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -279,7 +279,7 @@ static PollingEntry *first_polling_entry;
int qemu_add_polling_cb(PollingFunc *func, void *opaque)
{
PollingEntry **ppe, *pe;
- pe = g_malloc0(sizeof(PollingEntry));
+ pe = g_new0(PollingEntry, 1);
pe->func = func;
pe->opaque = opaque;
for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index 82d56507a2..2f4e21c482 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -102,7 +102,7 @@ QEMUTimerList *timerlist_new(QEMUClockType type,
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
- timer_list = g_malloc0(sizeof(QEMUTimerList));
+ timer_list = g_new0(QEMUTimerList, 1);
qemu_event_init(&timer_list->timers_done_ev, true);
timer_list->clock = clock;
timer_list->notify_cb = cb;
diff --git a/vl.c b/vl.c
index 3fed457921..9f82a375b3 100644
--- a/vl.c
+++ b/vl.c
@@ -1416,7 +1416,7 @@ static int add_semihosting_arg(void *opaque,
if (strcmp(name, "arg") == 0) {
s->argc++;
/* one extra element as g_strjoinv() expects NULL-terminated array */
- s->argv = g_realloc(s->argv, (s->argc + 1) * sizeof(void *));
+ s->argv = g_renew(const char *, s->argv, s->argc + 1);
s->argv[s->argc - 1] = val;
s->argv[s->argc] = NULL;
}
@@ -1589,7 +1589,7 @@ MachineInfoList *qmp_query_machines(Error **errp)
MachineInfoList *entry;
MachineInfo *info;
- info = g_malloc0(sizeof(*info));
+ info = g_new0(MachineInfo, 1);
if (mc->is_default) {
info->has_is_default = true;
info->is_default = true;
@@ -1604,7 +1604,7 @@ MachineInfoList *qmp_query_machines(Error **errp)
info->cpu_max = !mc->max_cpus ? 1 : mc->max_cpus;
info->hotpluggable_cpus = mc->has_hotpluggable_cpus;
- entry = g_malloc0(sizeof(*entry));
+ entry = g_new0(MachineInfoList, 1);
entry->value = info;
entry->next = mach_list;
mach_list = entry;
@@ -1657,7 +1657,7 @@ VMChangeStateEntry
*qemu_add_vm_change_state_handler(VMChangeStateHandler *cb,
{
VMChangeStateEntry *e;
- e = g_malloc0(sizeof (*e));
+ e = g_new0(VMChangeStateEntry, 1);
e->cb = cb;
e->opaque = opaque;
@@ -2546,7 +2546,7 @@ static void add_device_config(int type, const char
*cmdline)
{
struct device_config *conf;
- conf = g_malloc0(sizeof(*conf));
+ conf = g_new0(struct device_config, 1);
conf->type = type;
conf->cmdline = cmdline;
loc_save(&conf->loc);
@@ -3047,7 +3047,7 @@ static int global_init_func(void *opaque, QemuOpts *opts,
Error **errp)
{
GlobalProperty *g;
- g = g_malloc0(sizeof(*g));
+ g = g_new0(GlobalProperty, 1);
g->driver = qemu_opt_get(opts, "driver");
g->property = qemu_opt_get(opts, "property");
g->value = qemu_opt_get(opts, "value");
--
2.14.2
- [Qemu-trivial] [PATCH 08/88] BT: use g_new() family of functions, (continued)
- [Qemu-trivial] [PATCH 08/88] BT: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 09/88] Bootdevice: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 10/88] Character devices: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 11/88] Cryptodev Backends: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 12/88] backends/hostmem: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 13/88] Dirty Bitmaps: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 14/88] ui/vnc: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 15/88] ui/spice: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 17/88] Memory API: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 16/88] Main loop: use g_new() family of functions,
Philippe Mathieu-Daudé <=
- [Qemu-trivial] [PATCH 18/88] memory: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 19/88] exec: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 20/88] Migration: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 21/88] NBD: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 22/88] LM32: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 23/88] M68K: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06
- [Qemu-trivial] [PATCH 24/88] MIPS: use g_new() family of functions, Philippe Mathieu-Daudé, 2017/10/06