Signed-off-by: David Marchand <david.marchand@xxxxxxxxx> --- contrib/ivshmem-client/ivshmem-client.c | 9 ++------- contrib/ivshmem-server/ivshmem-server.c | 12 ++---------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/contrib/ivshmem-client/ivshmem-client.c b/contrib/ivshmem-client/ivshmem-client.c index 2ba40a7..a08f4d9 100644 --- a/contrib/ivshmem-client/ivshmem-client.c +++ b/contrib/ivshmem-client/ivshmem-client.c @@ -82,7 +82,7 @@ free_peer(IvshmemClient *client, IvshmemClientPeer *peer) close(peer->vectors[vector]); } - free(peer); + g_free(peer); } /* handle message coming from server (new peer, new vectors) */ @@ -116,12 +116,7 @@ handle_server_msg(IvshmemClient *client) /* new peer */ if (peer == NULL) { - peer = malloc(sizeof(*peer)); - if (peer == NULL) { - debug_log(client, "cannot allocate new peer\n"); - return -1; - } - memset(peer, 0, sizeof(*peer)); + peer = g_malloc0(sizeof(*peer)); peer->id = peer_id; peer->vectors_count = 0; QTAILQ_INSERT_TAIL(&client->peer_list, peer, next); diff --git a/contrib/ivshmem-server/ivshmem-server.c b/contrib/ivshmem-server/ivshmem-server.c index e0d4d1d..15d468c 100644 --- a/contrib/ivshmem-server/ivshmem-server.c +++ b/contrib/ivshmem-server/ivshmem-server.c @@ -90,7 +90,7 @@ free_peer(IvshmemServer *server, IvshmemServerPeer *peer) close(peer->vectors[vector]); } - free(peer); + g_free(peer); } /* send the peer id and the shm_fd just after a new client connection */ @@ -138,15 +138,7 @@ handle_new_conn(IvshmemServer *server) debug_log(server, "accept()=%d\n", newfd); /* allocate new structure for this peer */ - peer = malloc(sizeof(*peer)); - if (peer == NULL) { - debug_log(server, "cannot allocate new peer\n"); - close(newfd); - return -1; - } - - /* initialize the peer struct, one eventfd per vector */ - memset(peer, 0, sizeof(*peer)); + peer = g_malloc0(sizeof(*peer)); peer->sock_fd = newfd; /* get an unused peer id */ -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html