summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/rbthash.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-08 21:40:17 +0300
committerNiels de Vos <ndevos@redhat.com>2018-08-22 13:31:38 +0000
commit12510ece4f45a54452224c048abdce4af97b68cb (patch)
tree0172c9e9be219d38a33be62a02754cefc207d1f9 /libglusterfs/src/rbthash.c
parent7674ea878e934a072c5f40eafc78f7886b24808c (diff)
libglusterfs/src/rbthash.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: Ied400a500e36373d725f9480c5ebbe0a851f7c40
Diffstat (limited to 'libglusterfs/src/rbthash.c')
-rw-r--r--libglusterfs/src/rbthash.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index 06fc7ee35c8..4d654066e13 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -183,7 +183,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
}
entry->data = data;
- entry->key = GF_CALLOC (keylen, sizeof (char), gf_common_mt_char);
+ entry->key = GF_MALLOC (keylen, gf_common_mt_char);
if (!entry->key) {
goto free_entry;
}