From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f196.google.com (mail-lj1-f196.google.com [209.85.208.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id DDC4B4696C5 for ; Sat, 4 Apr 2020 19:16:27 +0300 (MSK) Received: by mail-lj1-f196.google.com with SMTP id 19so10091826ljj.7 for ; Sat, 04 Apr 2020 09:16:27 -0700 (PDT) From: Cyrill Gorcunov Date: Sat, 4 Apr 2020 19:15:21 +0300 Message-Id: <20200404161524.7466-6-gorcunov@gmail.com> In-Reply-To: <20200404161524.7466-1-gorcunov@gmail.com> References: <20200404161524.7466-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v11 5/8] box/replication: merge replica_by_id into replicaset List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml For some reason the replica_by_id member (which is an array of pointers) is allocated dynamically. Moreover VCLOCK_MAX = 32 by now and extending it to some new limit will require a way more efforts than just increase the number. Thus reserve memory for replica_by_id inside replicaset statically. This allows to simplify code a bit and drop calloc/free calls. The former code comes from edd76a2a0ae17e3d without any explanation why the dynamic member is needed. Signed-off-by: Cyrill Gorcunov --- src/box/replication.cc | 2 -- src/box/replication.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/box/replication.cc b/src/box/replication.cc index 1345f189b..7c10fb6f2 100644 --- a/src/box/replication.cc +++ b/src/box/replication.cc @@ -89,7 +89,6 @@ replication_init(void) rlist_create(&replicaset.anon); vclock_create(&replicaset.vclock); fiber_cond_create(&replicaset.applier.cond); - replicaset.replica_by_id = (struct replica **)calloc(VCLOCK_MAX, sizeof(struct replica *)); latch_create(&replicaset.applier.order_latch); vclock_create(&replicaset.applier.vclock); @@ -112,7 +111,6 @@ replication_free(void) relay_cancel(replica->relay); diag_destroy(&replicaset.applier.diag); - free(replicaset.replica_by_id); } int diff --git a/src/box/replication.h b/src/box/replication.h index 2ef1255b3..9df91e611 100644 --- a/src/box/replication.h +++ b/src/box/replication.h @@ -251,7 +251,7 @@ struct replicaset { struct diag diag; } applier; /** Map of all known replica_id's to correspponding replica's. */ - struct replica **replica_by_id; + struct replica *replica_by_id[VCLOCK_MAX]; }; extern struct replicaset replicaset; -- 2.20.1