[Pkg-libvirt-commits] [libguestfs] 24/36: btrfs: use calloc instead of malloc+memset

Hilko Bengen bengen at moszumanska.debian.org
Sun Nov 1 17:13:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag upstream/1.29.47
in repository libguestfs.

commit 3f4ba2e98d21746723d291939ccc2e1f1526aa6d
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Tue Jun 16 17:31:43 2015 +0200

    btrfs: use calloc instead of malloc+memset
    
    Small optimization, and eases the code.
---
 daemon/btrfs.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index f02acb1..7b14bac 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -1723,12 +1723,11 @@ do_btrfs_balance_status (const char *path)
 
   nlines = count_strings (lines);
 
-  ret = malloc(sizeof *ret);
+  ret = calloc (1, sizeof *ret);
   if (ret == NULL) {
-    reply_with_perror ("malloc");
+    reply_with_perror ("calloc");
     goto error;
   }
-  memset (ret, 0, sizeof(*ret));
 
   /* Output of `btrfs balance status' is like:
    *
@@ -1850,12 +1849,11 @@ do_btrfs_scrub_status (const char *path)
     return NULL;
   }
 
-  ret = malloc (sizeof *ret);
+  ret = calloc (1, sizeof *ret);
   if (ret == NULL) {
-    reply_with_perror ("malloc");
+    reply_with_perror ("calloc");
     return NULL;
   }
-  memset (ret, 0, sizeof(*ret));
 
   /* Output of `btrfs scrub -R status' is like:
    *

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list