From 54e5fae2bbea0086c7dd7951bb8776c3672fedf4 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Wed, 8 Aug 2018 21:41:10 +0300 Subject: libglusterfs/src/client_t.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: I58d2604ef684f94ea782fdbb1b1462fc7be53a9e --- libglusterfs/src/client_t.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index 046f72e021d..eb9e7a78b22 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -236,7 +236,7 @@ gf_client_get (xlator_t *this, struct rpcsvc_auth_data *cred, char *client_uid, client->auth.flavour = cred->flavour; if (cred->flavour != AUTH_NONE) { client->auth.data = - GF_CALLOC (1, cred->datalen, + GF_MALLOC (cred->datalen, gf_common_mt_client_t); if (client->auth.data == NULL) { GF_FREE (client->scratch_ctx.ctx); -- cgit