mirror of
https://github.com/mii443/qemu.git
synced 2025-08-30 10:59:53 +00:00
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
14
net/queue.c
14
net/queue.c
@ -63,7 +63,7 @@ NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver,
|
||||
{
|
||||
NetQueue *queue;
|
||||
|
||||
queue = qemu_mallocz(sizeof(NetQueue));
|
||||
queue = g_malloc0(sizeof(NetQueue));
|
||||
|
||||
queue->deliver = deliver;
|
||||
queue->deliver_iov = deliver_iov;
|
||||
@ -82,10 +82,10 @@ void qemu_del_net_queue(NetQueue *queue)
|
||||
|
||||
QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) {
|
||||
QTAILQ_REMOVE(&queue->packets, packet, entry);
|
||||
qemu_free(packet);
|
||||
g_free(packet);
|
||||
}
|
||||
|
||||
qemu_free(queue);
|
||||
g_free(queue);
|
||||
}
|
||||
|
||||
static ssize_t qemu_net_queue_append(NetQueue *queue,
|
||||
@ -97,7 +97,7 @@ static ssize_t qemu_net_queue_append(NetQueue *queue,
|
||||
{
|
||||
NetPacket *packet;
|
||||
|
||||
packet = qemu_malloc(sizeof(NetPacket) + size);
|
||||
packet = g_malloc(sizeof(NetPacket) + size);
|
||||
packet->sender = sender;
|
||||
packet->flags = flags;
|
||||
packet->size = size;
|
||||
@ -124,7 +124,7 @@ static ssize_t qemu_net_queue_append_iov(NetQueue *queue,
|
||||
max_len += iov[i].iov_len;
|
||||
}
|
||||
|
||||
packet = qemu_malloc(sizeof(NetPacket) + max_len);
|
||||
packet = g_malloc(sizeof(NetPacket) + max_len);
|
||||
packet->sender = sender;
|
||||
packet->sent_cb = sent_cb;
|
||||
packet->flags = flags;
|
||||
@ -227,7 +227,7 @@ void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from)
|
||||
QTAILQ_FOREACH_SAFE(packet, &queue->packets, entry, next) {
|
||||
if (packet->sender == from) {
|
||||
QTAILQ_REMOVE(&queue->packets, packet, entry);
|
||||
qemu_free(packet);
|
||||
g_free(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,6 +255,6 @@ void qemu_net_queue_flush(NetQueue *queue)
|
||||
packet->sent_cb(packet->sender, ret);
|
||||
}
|
||||
|
||||
qemu_free(packet);
|
||||
g_free(packet);
|
||||
}
|
||||
}
|
||||
|
22
net/slirp.c
22
net/slirp.c
@ -450,7 +450,7 @@ int net_slirp_redir(const char *redir_str)
|
||||
struct slirp_config_str *config;
|
||||
|
||||
if (QTAILQ_EMPTY(&slirp_stacks)) {
|
||||
config = qemu_malloc(sizeof(*config));
|
||||
config = g_malloc(sizeof(*config));
|
||||
pstrcpy(config->str, sizeof(config->str), redir_str);
|
||||
config->flags = SLIRP_CFG_HOSTFWD | SLIRP_CFG_LEGACY;
|
||||
config->next = slirp_configs;
|
||||
@ -614,19 +614,19 @@ static int slirp_guestfwd(SlirpState *s, const char *config_str,
|
||||
goto fail_syntax;
|
||||
}
|
||||
|
||||
fwd = qemu_malloc(sizeof(struct GuestFwd));
|
||||
fwd = g_malloc(sizeof(struct GuestFwd));
|
||||
snprintf(buf, sizeof(buf), "guestfwd.tcp.%d", port);
|
||||
fwd->hd = qemu_chr_open(buf, p, NULL);
|
||||
if (!fwd->hd) {
|
||||
error_report("could not open guest forwarding device '%s'", buf);
|
||||
qemu_free(fwd);
|
||||
g_free(fwd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (slirp_add_exec(s->slirp, 3, fwd->hd, &server, port) < 0) {
|
||||
error_report("conflicting/invalid host:port in guest forwarding "
|
||||
"rule '%s'", config_str);
|
||||
qemu_free(fwd);
|
||||
g_free(fwd);
|
||||
return -1;
|
||||
}
|
||||
fwd->server = server;
|
||||
@ -662,7 +662,7 @@ static int net_init_slirp_configs(const char *name, const char *value, void *opa
|
||||
return 0;
|
||||
}
|
||||
|
||||
config = qemu_mallocz(sizeof(*config));
|
||||
config = g_malloc0(sizeof(*config));
|
||||
|
||||
pstrcpy(config->str, sizeof(config->str), value);
|
||||
|
||||
@ -720,7 +720,7 @@ int net_init_slirp(QemuOpts *opts,
|
||||
const char *ip = qemu_opt_get(opts, "ip");
|
||||
int l = strlen(ip) + strlen("/24") + 1;
|
||||
|
||||
vnet = qemu_malloc(l);
|
||||
vnet = g_malloc(l);
|
||||
|
||||
/* emulate legacy ip= parameter */
|
||||
pstrcpy(vnet, l, ip);
|
||||
@ -729,9 +729,9 @@ int net_init_slirp(QemuOpts *opts,
|
||||
|
||||
if (qemu_opt_get(opts, "net")) {
|
||||
if (vnet) {
|
||||
qemu_free(vnet);
|
||||
g_free(vnet);
|
||||
}
|
||||
vnet = qemu_strdup(qemu_opt_get(opts, "net"));
|
||||
vnet = g_strdup(qemu_opt_get(opts, "net"));
|
||||
}
|
||||
|
||||
qemu_opt_foreach(opts, net_init_slirp_configs, NULL, 0);
|
||||
@ -743,10 +743,10 @@ int net_init_slirp(QemuOpts *opts,
|
||||
while (slirp_configs) {
|
||||
config = slirp_configs;
|
||||
slirp_configs = config->next;
|
||||
qemu_free(config);
|
||||
g_free(config);
|
||||
}
|
||||
|
||||
qemu_free(vnet);
|
||||
g_free(vnet);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -764,7 +764,7 @@ int net_slirp_parse_legacy(QemuOptsList *opts_list, const char *optarg, int *ret
|
||||
if (QTAILQ_EMPTY(&slirp_stacks)) {
|
||||
struct slirp_config_str *config;
|
||||
|
||||
config = qemu_malloc(sizeof(*config));
|
||||
config = g_malloc(sizeof(*config));
|
||||
pstrcpy(config->str, sizeof(config->str), optarg);
|
||||
config->flags = SLIRP_CFG_LEGACY;
|
||||
config->next = slirp_configs;
|
||||
|
@ -404,7 +404,7 @@ static int net_socket_listen_init(VLANState *vlan,
|
||||
if (parse_host_port(&saddr, host_str) < 0)
|
||||
return -1;
|
||||
|
||||
s = qemu_mallocz(sizeof(NetSocketListenState));
|
||||
s = g_malloc0(sizeof(NetSocketListenState));
|
||||
|
||||
fd = qemu_socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (fd < 0) {
|
||||
@ -428,8 +428,8 @@ static int net_socket_listen_init(VLANState *vlan,
|
||||
return -1;
|
||||
}
|
||||
s->vlan = vlan;
|
||||
s->model = qemu_strdup(model);
|
||||
s->name = name ? qemu_strdup(name) : NULL;
|
||||
s->model = g_strdup(model);
|
||||
s->name = name ? g_strdup(name) : NULL;
|
||||
s->fd = fd;
|
||||
qemu_set_fd_handler(fd, net_socket_accept, NULL, s);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user