From f6a7f6e8124327509559170faa9a4dce6fad9731 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Tue, 21 Aug 2018 23:36:28 +0300 Subject: xlators/cluster/dht/src/dht-common.c :move to GF_MALLOC() instead of GF_CALLOC() when 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. Please review carefully, especially for string allocation, with the terminating NULL string (added another byte to ensure it's there). Only compile-tested! Change-Id: Ia5e4f50dfb0c29809c2019fcfd8079507813249e updates: bz#1193929 Signed-off-by: Yaniv Kaul --- xlators/cluster/dht/src/dht-common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 69555a22e5e..5f64d5c254d 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -11477,12 +11477,12 @@ dht_log_new_layout_for_dir_selfheal (xlator_t *this, loc_t *loc, len++; - output_string = GF_CALLOC (len, sizeof (char), gf_common_mt_char); + output_string = GF_MALLOC (len + 1, gf_common_mt_char); if (!output_string) return; - ret = snprintf (output_string, len, "Setting layout of %s with ", + ret = snprintf (output_string, len + 1, "Setting layout of %s with ", loc->path); if (ret < 0) -- cgit