From 12510ece4f45a54452224c048abdce4af97b68cb Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Wed, 8 Aug 2018 21:40:17 +0300 Subject: 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 Change-Id: Ied400a500e36373d725f9480c5ebbe0a851f7c40 --- libglusterfs/src/rbthash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } -- cgit