[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 12/12] fix qemu_alloc/qemu_free for main director
From: |
Jean-Christophe DUBOIS |
Subject: |
[Qemu-devel] [PATCH v4 12/12] fix qemu_alloc/qemu_free for main directory |
Date: |
Thu, 18 Jun 2009 22:50:19 +0200 |
From: Jean-Christophe Dubois <address@hidden(none)>
Signed-off-by: Jean-Christophe DUBOIS <address@hidden>
---
acl.c | 4 ++--
migration.c | 2 +-
net.c | 30 +++++++++++++++---------------
qemu-char.c | 12 ++++++------
qemu-img.c | 2 +-
qemu-io.c | 12 ++++++------
readline.c | 2 +-
vl.c | 6 +++---
8 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/acl.c b/acl.c
index f69db25..3b1013c 100644
--- a/acl.c
+++ b/acl.c
@@ -104,8 +104,8 @@ void qemu_acl_reset(qemu_acl *acl)
acl->defaultDeny = 1;
TAILQ_FOREACH(entry, &acl->entries, next) {
TAILQ_REMOVE(&acl->entries, entry, next);
- free(entry->match);
- free(entry);
+ qemu_free(entry->match);
+ qemu_free(entry);
}
acl->nentries = 0;
}
diff --git a/migration.c b/migration.c
index 190b37e..42e3578 100644
--- a/migration.c
+++ b/migration.c
@@ -306,7 +306,7 @@ void migrate_fd_release(MigrationState *mig_state)
s->state = MIG_STATE_CANCELLED;
migrate_fd_cleanup(s);
}
- free(s);
+ qemu_free(s);
}
void migrate_fd_wait_for_unfreeze(void *opaque)
diff --git a/net.c b/net.c
index af9de73..1daa62b 100644
--- a/net.c
+++ b/net.c
@@ -214,7 +214,7 @@ int parse_host_src_port(struct sockaddr_in *haddr,
struct sockaddr_in *saddr,
const char *input_str)
{
- char *str = strdup(input_str);
+ char *str = qemu_strdup(input_str);
char *host_str = str;
char *src_str;
const char *src_str2;
@@ -243,11 +243,11 @@ int parse_host_src_port(struct sockaddr_in *haddr,
if (parse_host_port(saddr, src_str2) < 0)
goto fail;
- free(str);
+ qemu_free(str);
return(0);
fail:
- free(str);
+ qemu_free(str);
return -1;
}
@@ -326,7 +326,7 @@ static char *assign_name(VLANClientState *vc1, const char
*model)
snprintf(buf, sizeof(buf), "%s.%d", model, id);
- return strdup(buf);
+ return qemu_strdup(buf);
}
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
@@ -340,9 +340,9 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
{
VLANClientState *vc, **pvc;
vc = qemu_mallocz(sizeof(VLANClientState));
- vc->model = strdup(model);
+ vc->model = qemu_strdup(model);
if (name)
- vc->name = strdup(name);
+ vc->name = qemu_strdup(name);
else
vc->name = assign_name(vc, model);
vc->can_receive = can_receive;
@@ -370,8 +370,8 @@ void qemu_del_vlan_client(VLANClientState *vc)
if (vc->cleanup) {
vc->cleanup(vc);
}
- free(vc->name);
- free(vc->model);
+ qemu_free(vc->name);
+ qemu_free(vc->model);
qemu_free(vc);
break;
} else
@@ -1462,7 +1462,7 @@ static int net_vde_init(VLANState *vlan, const char
*model,
s = qemu_mallocz(sizeof(VDEState));
s->vde = vde_open(init_sock, (char *)"QEMU", &args);
if (!s->vde){
- free(s);
+ qemu_free(s);
return -1;
}
s->vc = qemu_new_vlan_client(vlan, model, name, NULL, vde_receive,
@@ -1831,8 +1831,8 @@ static int net_socket_listen_init(VLANState *vlan,
return -1;
}
s->vlan = vlan;
- s->model = strdup(model);
- s->name = name ? strdup(name) : NULL;
+ s->model = qemu_strdup(model);
+ s->name = name ? qemu_strdup(name) : NULL;
s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0;
@@ -2064,7 +2064,7 @@ void qemu_check_nic_model_list(NICInfo *nd, const char *
const *models,
int i, exit_status = 0;
if (!nd->model)
- nd->model = strdup(default_model);
+ nd->model = qemu_strdup(default_model);
if (strcmp(nd->model, "?") != 0) {
for (i = 0 ; models[i]; i++)
@@ -2136,7 +2136,7 @@ int net_client_init(Monitor *mon, const char *device,
const char *p)
}
}
if (get_param_value(buf, sizeof(buf), "model", p)) {
- nd->model = strdup(buf);
+ nd->model = qemu_strdup(buf);
}
nd->vlan = vlan;
nd->name = name;
@@ -2193,7 +2193,7 @@ int net_client_init(Monitor *mon, const char *device,
const char *p)
ret = -1;
goto out;
}
- vmc = malloc(sizeof(struct VMChannel));
+ vmc = qemu_malloc(sizeof(struct VMChannel));
snprintf(name, 20, "vmchannel%ld", port);
vmc->hd = qemu_chr_open(name, devname, NULL);
if (!vmc->hd) {
@@ -2379,7 +2379,7 @@ void net_client_uninit(NICInfo *nd)
nd->vlan->nb_guest_devs--;
nb_nics--;
nd->used = 0;
- free((void *)nd->model);
+ qemu_free((void *)nd->model);
}
static int net_host_check_device(const char *device)
diff --git a/qemu-char.c b/qemu-char.c
index 287e0cd..455bf9b 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1559,8 +1559,8 @@ static CharDriverState *qemu_chr_open_win(const char
*filename)
chr->chr_close = win_chr_close;
if (win_chr_init(chr, filename) < 0) {
- free(s);
- free(chr);
+ qemu_free(s);
+ qemu_free(chr);
return NULL;
}
qemu_chr_reset(chr);
@@ -1658,8 +1658,8 @@ static CharDriverState *qemu_chr_open_win_pipe(const char
*filename)
chr->chr_close = win_chr_close;
if (win_chr_pipe_init(chr, filename) < 0) {
- free(s);
- free(chr);
+ qemu_free(s);
+ qemu_free(chr);
return NULL;
}
qemu_chr_reset(chr);
@@ -1814,9 +1814,9 @@ static CharDriverState *qemu_chr_open_udp(const char *def)
return_err:
if (chr)
- free(chr);
+ qemu_free(chr);
if (s)
- free(s);
+ qemu_free(s);
if (fd >= 0)
closesocket(fd);
return NULL;
diff --git a/qemu-img.c b/qemu-img.c
index d806cfa..ed9186d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -787,7 +787,7 @@ static int img_convert(int argc, char **argv)
bdrv_delete(out_bs);
for (bs_i = 0; bs_i < bs_n; bs_i++)
bdrv_delete(bs[bs_i]);
- free(bs);
+ qemu_free(bs);
return 0;
}
diff --git a/qemu-io.c b/qemu-io.c
index f0a17b9..78a78e3 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -310,15 +310,15 @@ read_f(int argc, char **argv)
return 0;
}
- if (Pflag) {
- void* cmp_buf = malloc(pattern_count);
+ if (Pflag && pattern_count) {
+ void* cmp_buf = qemu_malloc(pattern_count);
memset(cmp_buf, pattern, pattern_count);
if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
printf("Pattern verification failed at offset %lld, "
"%d bytes\n",
(long long) offset + pattern_offset,
pattern_count);
}
- free(cmp_buf);
+ qemu_free(cmp_buf);
}
if (qflag)
@@ -464,15 +464,15 @@ readv_f(int argc, char **argv)
return 0;
}
- if (Pflag) {
- void* cmp_buf = malloc(count);
+ if (Pflag && count) {
+ void* cmp_buf = qemu_malloc(count);
memset(cmp_buf, pattern, count);
if (memcmp(buf, cmp_buf, count)) {
printf("Pattern verification failed at offset %lld, "
"%d bytes\n",
(long long) offset, count);
}
- free(cmp_buf);
+ qemu_free(cmp_buf);
}
if (qflag)
diff --git a/readline.c b/readline.c
index 7834af0..be592ac 100644
--- a/readline.c
+++ b/readline.c
@@ -246,7 +246,7 @@ static void readline_hist_add(ReadLineState *rs, const char
*cmdline)
}
if (idx == READLINE_MAX_CMDS) {
/* Need to get one free slot */
- free(rs->history[0]);
+ qemu_free(rs->history[0]);
memcpy(rs->history, &rs->history[1],
(READLINE_MAX_CMDS - 1) * sizeof(char *));
rs->history[READLINE_MAX_CMDS - 1] = NULL;
diff --git a/vl.c b/vl.c
index 3242c23..27a5773 100644
--- a/vl.c
+++ b/vl.c
@@ -1072,7 +1072,7 @@ static void configure_alarms(char const *opt)
exit(0);
}
- arg = strdup(opt);
+ arg = qemu_strdup(opt);
/* Reorder the array */
name = strtok(arg, ",");
@@ -1101,7 +1101,7 @@ next:
name = strtok(NULL, ",");
}
- free(arg);
+ qemu_free(arg);
if (cur) {
/* Disable remaining timers */
@@ -4913,7 +4913,7 @@ char *qemu_find_file(int type, const char *name)
/* If name contains path separators then try it as a straight path. */
if ((strchr(name, '/') || strchr(name, '\\'))
&& access(name, R_OK) == 0) {
- return strdup(name);
+ return qemu_strdup(name);
}
switch (type) {
case QEMU_FILE_TYPE_BIOS:
--
1.6.0.4
- [Qemu-devel] [PATCH v4 02/12] fix qemu_alloc/qemu_free for hw subsystem, (continued)
- [Qemu-devel] [PATCH v4 02/12] fix qemu_alloc/qemu_free for hw subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 03/12] fix qemu_alloc/qemu_free for bsd-user subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 05/12] fix qemu_alloc/qemu_free for target-i386 subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 06/12] fix qemu_alloc/qemu_free for slirp subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 07/12] fix qemu_alloc/qemu_free for audio subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 08/12] fix qemu_alloc/qemu_free for target-arm subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 09/12] fix qemu_alloc/qemu_free for target-ppc subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 10/12] fix qemu_alloc/qemu_free for target-sparc subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 11/12] fix qemu_alloc/qemu_free for tcg subsystem, Jean-Christophe DUBOIS, 2009/06/18
- [Qemu-devel] [PATCH v4 12/12] fix qemu_alloc/qemu_free for main directory,
Jean-Christophe DUBOIS <=
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, vibi sreenivasan, 2009/06/19
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe Dubois, 2009/06/19
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, vibi sreenivasan, 2009/06/20
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Jean-Christophe Dubois, 2009/06/20
- Re: [Qemu-devel] [PATCH v4 04/12] fix qemu_alloc/qemu_free for linux-user subsystem, Andreas Färber, 2009/06/20
Re: [Qemu-devel] [PATCH v4 01/12] fix qemu_alloc/qemu_free for block subsystem, Kevin Wolf, 2009/06/19