summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-08 21:40:29 +0300
committerNiels de Vos <ndevos@redhat.com>2018-08-22 15:17:49 +0000
commitbfba1d3602b20895956767c668e86390f16cb782 (patch)
tree24d4d9328b26c4c127fff6be8c779e78d69e5a88 /libglusterfs
parent443aa8e582f0dd5c4df916c0240eee3c0b56fe3f (diff)
downloadglusterfs-bfba1d3602b20895956767c668e86390f16cb782.tar.gz
glusterfs-bfba1d3602b20895956767c668e86390f16cb782.tar.xz
glusterfs-bfba1d3602b20895956767c668e86390f16cb782.zip
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 <ykaul@redhat.com> Change-Id: Icd990423a5e6048e76922668aab67422f4bc1867
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/graph.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index 2a171f3b8d..26dfc4e6b8 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;