From 942c711f95de3f47d0abc056b934ed2ac7cc636b Mon Sep 17 00:00:00 2001 Message-Id: <942c711f95de3f47d0abc056b934ed2ac7cc636b.1367947969.git.minovotn@redhat.com> In-Reply-To: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com> References: <707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com> From: Michal Novotny Date: Tue, 7 May 2013 18:36:21 +0200 Subject: [PATCH 010/114] Revert "qga: convert qemu_mallocz() to g_malloc0() and qemu_free() to g_free()" This reverts commit 69676a90dfa7e8d6441ad30fbfafc2318e617776. Reverting as asked by Laszlo in message <51892739.2030807@redhat.com> because of the ordering issue (most likely) related to supersed testing. Signed-off-by: Michal Novotny --- qga/commands-posix.c | 30 +++++++++++++++--------------- qga/commands.c | 2 +- qga/guest-agent-command-state.c | 4 ++-- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index a009321..8c43e5b 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -209,7 +209,7 @@ static void guest_file_handle_add(FILE *fh) { GuestFileHandle *gfh; - gfh = g_malloc0(sizeof(GuestFileHandle)); + gfh = qemu_mallocz(sizeof(GuestFileHandle)); gfh->id = fileno(fh); gfh->fh = fh; QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next); @@ -280,7 +280,7 @@ void qmp_guest_file_close(int64_t handle, Error **err) } QTAILQ_REMOVE(&guest_file_state.filehandles, gfh, next); - g_free(gfh); + qemu_free(gfh); } struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, @@ -304,21 +304,21 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count, } fh = gfh->fh; - buf = g_malloc0(count+1); + buf = qemu_mallocz(count+1); read_count = fread(buf, 1, count, fh); if (ferror(fh)) { slog("guest-file-read failed, handle: %ld", handle); error_set(err, QERR_QGA_COMMAND_FAILED, "fread() failed"); } else { buf[read_count] = 0; - read_data = g_malloc0(sizeof(GuestFileRead)); + read_data = qemu_mallocz(sizeof(GuestFileRead)); read_data->count = read_count; read_data->eof = feof(fh); if (read_count) { read_data->buf_b64 = g_base64_encode(buf, read_count); } } - g_free(buf); + qemu_free(buf); clearerr(fh); return read_data; @@ -344,7 +344,7 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, if (!has_count) { count = buf_len; } else if (count < 0 || count > buf_len) { - g_free(buf); + qemu_free(buf); error_set(err, QERR_INVALID_PARAMETER, "count"); return NULL; } @@ -354,11 +354,11 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, slog("guest-file-write failed, handle: %ld", handle); error_set(err, QERR_QGA_COMMAND_FAILED, "fwrite() error"); } else { - write_data = g_malloc0(sizeof(GuestFileWrite)); + write_data = qemu_mallocz(sizeof(GuestFileWrite)); write_data->count = write_count; write_data->eof = feof(fh); } - g_free(buf); + qemu_free(buf); clearerr(fh); return write_data; @@ -381,7 +381,7 @@ struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset, if (ret == -1) { error_set(err, QERR_QGA_COMMAND_FAILED, strerror(errno)); } else { - seek_data = g_malloc0(sizeof(GuestFileRead)); + seek_data = qemu_mallocz(sizeof(GuestFileRead)); seek_data->position = ftell(fh); seek_data->eof = feof(fh); } @@ -983,8 +983,8 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) info = guest_find_interface(head, ifa->ifa_name); if (!info) { - info = g_malloc0(sizeof(*info)); - info->value = g_malloc0(sizeof(*info->value)); + info = qemu_mallocz(sizeof(*info)); + info->value = qemu_mallocz(sizeof(*info->value)); info->value->name = g_strdup(ifa->ifa_name); if (!cur_item) { @@ -1037,8 +1037,8 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) { /* interface with IPv4 address */ - address_item = g_malloc0(sizeof(*address_item)); - address_item->value = g_malloc0(sizeof(*address_item->value)); + address_item = qemu_mallocz(sizeof(*address_item)); + address_item->value = qemu_mallocz(sizeof(*address_item->value)); p = &((struct sockaddr_in *)ifa->ifa_addr)->sin_addr; if (!inet_ntop(AF_INET, p, addr4, sizeof(addr4))) { snprintf(err_msg, sizeof(err_msg), @@ -1059,8 +1059,8 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp) } else if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET6) { /* interface with IPv6 address */ - address_item = g_malloc0(sizeof(*address_item)); - address_item->value = g_malloc0(sizeof(*address_item->value)); + address_item = qemu_mallocz(sizeof(*address_item)); + address_item->value = qemu_mallocz(sizeof(*address_item->value)); p = &((struct sockaddr_in6 *)ifa->ifa_addr)->sin6_addr; if (!inet_ntop(AF_INET6, p, addr6, sizeof(addr6))) { snprintf(err_msg, sizeof(err_msg), diff --git a/qga/commands.c b/qga/commands.c index 248110e..5a8e800 100644 --- a/qga/commands.c +++ b/qga/commands.c @@ -47,7 +47,7 @@ void qmp_guest_ping(Error **err) struct GuestAgentInfo *qmp_guest_info(Error **err) { - GuestAgentInfo *info = g_malloc0(sizeof(GuestAgentInfo)); + GuestAgentInfo *info = qemu_mallocz(sizeof(GuestAgentInfo)); GuestAgentCommandInfo *cmd_info; GuestAgentCommandInfoList *cmd_info_list; char **cmd_list_head, **cmd_list; diff --git a/qga/guest-agent-command-state.c b/qga/guest-agent-command-state.c index 969da23..bc6e0bd 100644 --- a/qga/guest-agent-command-state.c +++ b/qga/guest-agent-command-state.c @@ -27,7 +27,7 @@ void ga_command_state_add(GACommandState *cs, void (*init)(void), void (*cleanup)(void)) { - GACommandGroup *cg = g_malloc0(sizeof(GACommandGroup)); + GACommandGroup *cg = qemu_mallocz(sizeof(GACommandGroup)); cg->init = init; cg->cleanup = cleanup; cs->groups = g_slist_append(cs->groups, cg); @@ -67,7 +67,7 @@ void ga_command_state_cleanup_all(GACommandState *cs) GACommandState *ga_command_state_new(void) { - GACommandState *cs = g_malloc0(sizeof(GACommandState)); + GACommandState *cs = qemu_mallocz(sizeof(GACommandState)); cs->groups = NULL; return cs; } -- 1.7.11.7