Use qemu_strdup() for VLANClientState string fields

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
master
Mark McLoughlin 2009-10-06 12:16:55 +01:00 committed by Anthony Liguori
parent d2cffe303e
commit 02374aa02a
1 changed files with 7 additions and 7 deletions

14
net.c
View File

@ -296,7 +296,7 @@ static char *assign_name(VLANClientState *vc1, const char *model)
snprintf(buf, sizeof(buf), "%s.%d", model, id); snprintf(buf, sizeof(buf), "%s.%d", model, id);
return strdup(buf); return qemu_strdup(buf);
} }
VLANClientState *qemu_new_vlan_client(VLANState *vlan, VLANClientState *qemu_new_vlan_client(VLANState *vlan,
@ -310,9 +310,9 @@ VLANClientState *qemu_new_vlan_client(VLANState *vlan,
{ {
VLANClientState *vc, **pvc; VLANClientState *vc, **pvc;
vc = qemu_mallocz(sizeof(VLANClientState)); vc = qemu_mallocz(sizeof(VLANClientState));
vc->model = strdup(model); vc->model = qemu_strdup(model);
if (name) if (name)
vc->name = strdup(name); vc->name = qemu_strdup(name);
else else
vc->name = assign_name(vc, model); vc->name = assign_name(vc, model);
vc->can_receive = can_receive; vc->can_receive = can_receive;
@ -340,8 +340,8 @@ void qemu_del_vlan_client(VLANClientState *vc)
if (vc->cleanup) { if (vc->cleanup) {
vc->cleanup(vc); vc->cleanup(vc);
} }
free(vc->name); qemu_free(vc->name);
free(vc->model); qemu_free(vc->model);
qemu_free(vc); qemu_free(vc);
break; break;
} else } else
@ -2127,8 +2127,8 @@ static int net_socket_listen_init(VLANState *vlan,
return -1; return -1;
} }
s->vlan = vlan; s->vlan = vlan;
s->model = strdup(model); s->model = qemu_strdup(model);
s->name = name ? strdup(name) : NULL; s->name = name ? qemu_strdup(name) : NULL;
s->fd = fd; s->fd = fd;
qemu_set_fd_handler(fd, net_socket_accept, NULL, s); qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
return 0; return 0;