From: Huawei Xie Date: Thu, 25 Jun 2015 05:47:36 +0000 (+0800) Subject: vhost: use rte_malloc to allocate device and queues X-Git-Tag: spdx-start~8922 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4113e38100fc2763244cea4588f5097fdda709ea;p=dpdk.git vhost: use rte_malloc to allocate device and queues use rte_malloc to allocate vhost device and queues Signed-off-by: Huawei Xie --- diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c index fced2ab98c..8b59c02ab2 100644 --- a/lib/librte_vhost/virtio-net.c +++ b/lib/librte_vhost/virtio-net.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include "vhost-net.h" @@ -203,9 +204,9 @@ static void free_device(struct virtio_net_config_ll *ll_dev) { /* Free any malloc'd memory */ - free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); - free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); - free(ll_dev); + rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); + rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); + rte_free(ll_dev); } /* @@ -279,7 +280,7 @@ new_device(struct vhost_device_ctx ctx) struct vhost_virtqueue *virtqueue_rx, *virtqueue_tx; /* Setup device and virtqueues. */ - new_ll_dev = malloc(sizeof(struct virtio_net_config_ll)); + new_ll_dev = rte_malloc(NULL, sizeof(struct virtio_net_config_ll), 0); if (new_ll_dev == NULL) { RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for dev.\n", @@ -287,19 +288,19 @@ new_device(struct vhost_device_ctx ctx) return -1; } - virtqueue_rx = malloc(sizeof(struct vhost_virtqueue)); + virtqueue_rx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); if (virtqueue_rx == NULL) { - free(new_ll_dev); + rte_free(new_ll_dev); RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for rxq.\n", ctx.fh); return -1; } - virtqueue_tx = malloc(sizeof(struct vhost_virtqueue)); + virtqueue_tx = rte_malloc(NULL, sizeof(struct vhost_virtqueue), 0); if (virtqueue_tx == NULL) { - free(virtqueue_rx); - free(new_ll_dev); + rte_free(virtqueue_rx); + rte_free(new_ll_dev); RTE_LOG(ERR, VHOST_CONFIG, "(%"PRIu64") Failed to allocate memory for txq.\n", ctx.fh);