diff mbox series

[6/8] tools/virtiofsd/buffer.c: replaced a calloc call with GLib's g_try_new0

Message ID 20210314032324.45142-7-ma.mandourr@gmail.com (mailing list archive)
State New, archived
Headers show
Series Replacing malloc and the like with GLib's variants | expand

Commit Message

Mahmoud Mandour March 14, 2021, 3:23 a.m. UTC
Replaced a call to calloc() and its respective free() call
with GLib's g_try_new0() and g_free() calls.

Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
---
 tools/virtiofsd/buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefan Hajnoczi March 15, 2021, 9:53 a.m. UTC | #1
On Sun, Mar 14, 2021 at 05:23:22AM +0200, Mahmoud Mandour wrote:
> Replaced a call to calloc() and its respective free() call
> with GLib's g_try_new0() and g_free() calls.
> 
> Signed-off-by: Mahmoud Mandour <ma.mandourr@gmail.com>
> ---
>  tools/virtiofsd/buffer.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c
index 874f01c488..b5f04be356 100644
--- a/tools/virtiofsd/buffer.c
+++ b/tools/virtiofsd/buffer.c
@@ -37,7 +37,7 @@  static ssize_t fuse_buf_writev(struct fuse_buf *out_buf,
     struct iovec *iov;
     int fd = out_buf->fd;
 
-    iov = calloc(iovcnt, sizeof(struct iovec));
+    iov = g_try_new0(struct iovec, iovcnt);
     if (!iov) {
         return -ENOMEM;
     }
@@ -61,7 +61,7 @@  static ssize_t fuse_buf_writev(struct fuse_buf *out_buf,
         res = -errno;
     }
 
-    free(iov);
+    g_free(iov);
     return res;
 }