diff options
authorYaniv Kaul <>2018-08-08 21:40:29 +0300
committerNiels de Vos <>2018-08-22 15:17:49 +0000
commitbfba1d3602b20895956767c668e86390f16cb782 (patch)
parent443aa8e582f0dd5c4df916c0240eee3c0b56fe3f (diff)
libglusterfs/src/graph.c: Move to GF_MALLOC() instead of GF_CALLOC() when possible
It doesn't make sense to calloc (allocate and clear) memory when the code right away fills that memory with data. It may be optimized by the compiler, or have a microscopic performance improvement. In some cases, also changed allocation size to be sizeof some struct or type instead of a pointer - easier to read. In some cases, removed redundant strlen() calls by saving the result into a variable. 1. Only done for the straightforward cases. There's room for improvement. 2. Please review carefully, especially for string allocation, with the terminating NULL string. Only compile-tested! updates: bz#1193929 Signed-off-by: Yaniv Kaul <> Change-Id: Icd990423a5e6048e76922668aab67422f4bc1867
1 files changed, 1 insertions, 2 deletions
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 2a171f3b8dc..26dfc4e6b81 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -1178,8 +1178,7 @@ glusterfs_graph_attach (glusterfs_graph_t *orig_graph, char *path,
file_len = stbuf.st_size;
- volfile_content = GF_CALLOC (file_len+1, sizeof (char),
- gf_common_mt_char);
+ volfile_content = GF_MALLOC (file_len+1, gf_common_mt_char);
if (!volfile_content)
return -ENOMEM;