From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C6645A0471 for ; Thu, 18 Jul 2019 19:18:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id EBFF9532C; Thu, 18 Jul 2019 19:18:28 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 2A8C03977 for ; Thu, 18 Jul 2019 19:18:22 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id i70so2444597pgd.4 for ; Thu, 18 Jul 2019 10:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=N1WVl4UQRTpsyytnCtNAVwaiTrTPmL/dbLCjaW6bKtI=; b=07rsIpMvaw3Jf7ySy6COdZlMLbrjnBvxVG2ARZ/bvTy55xAhnCpzRC3/2mndptV+Ol gGiqnAD9pTsSoToeAoHR6tH8OCAWyE5+6p3DW3YIIxXLJPRdQrXyKTr/Dq6xvJ7xe747 7VuKcPVTwGPXCPqZkgzvP+SmsIg00uxXzkf2HkLETI4DHicoGGPLvxQBto/ZS6xFgNa0 moiYujchoKZ2q9mOk+vfN7N3xjAkgBOBB5i6TanHDL/6Umpt92VtcrVXhdmH/8ec4NaN tPnLHFLqBuRgBTcTeGEy5XuwT7xvnZX7VpTFbnRwh3YrpJ6iLK7ZQj83gLhz9omf8f3i BbvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=N1WVl4UQRTpsyytnCtNAVwaiTrTPmL/dbLCjaW6bKtI=; b=itTc0MdzL2n0WigYjQazS3GblBfoK7q/Wu0GWrynGtMNZbBGKc1CWsBquwS4gJnaqa sUF5CZt+uCAOeFQ7eFCUnb+0CpmiJ6yF5tZUHMgxPnbjDi4bpaC8NueehDkStwqk2CJu afIDw7j02pVUUFHE4CJPzPosa787uJ5HzMWXvk8PS7Jo91hmbD6Jjp+sagPVCxy+O5Av /zuAyhvkP6GTlv0hTfOJxgT1AiXk7w+pVqJ2JxUJlM/OeuF6MJLAhZeQrqiVUuhEH/dJ K1b6V3yv7jlI/Sb6pOtCniqQxB3VdhLf5vWFzjRcI67ho37w0WIlA4a1Z8ntn+fEE3y5 9rZQ== X-Gm-Message-State: APjAAAV/ptOfAxOmcNfGIaqpnKDHy269XdCHMZ5n2pQzbpOdHxpYGGoE X9TS/gRsHOEQRxX7DsVmHvY9QX/Q X-Google-Smtp-Source: APXvYqxmOnhGIqcbfke3PAx8nBV5sXFxjIuqRNB2GRcLY+hTQWgPJNfMPST+fncIQf9X8wUGgyhguA== X-Received: by 2002:a17:90a:cb81:: with SMTP id a1mr50872227pju.81.1563470301011; Thu, 18 Jul 2019 10:18:21 -0700 (PDT) Received: from localhost.localdomain ([67.23.203.6]) by smtp.gmail.com with ESMTPSA id 137sm36038021pfz.112.2019.07.18.10.18.17 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 18 Jul 2019 10:18:18 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Thu, 18 Jul 2019 10:18:12 -0700 Message-Id: <20190718171812.3209-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190718171812.3209-1-stephen@networkplumber.org> References: <20190716172741.21399-1-stephen@networkplumber.org> <20190718171812.3209-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v3 3/3] cfgfile: use calloc X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Better to use calloc when allocating arrays. Signed-off-by: Stephen Hemminger --- lib/librte_cfgfile/rte_cfgfile.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index 388415147930..9049fd9c2319 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -281,17 +281,16 @@ rte_cfgfile_create(int flags) cfg->num_sections = 0; /* allocate first batch of sections and entries */ - cfg->sections = malloc(sizeof(struct rte_cfgfile_section) * - CFG_ALLOC_SECTION_BATCH); - + cfg->sections = calloc(CFG_ALLOC_SECTION_BATCH, + sizeof(struct rte_cfgfile_section)); if (cfg->sections == NULL) goto error1; cfg->allocated_sections = CFG_ALLOC_SECTION_BATCH; for (i = 0; i < CFG_ALLOC_SECTION_BATCH; i++) { - cfg->sections[i].entries = malloc(sizeof( - struct rte_cfgfile_entry) * CFG_ALLOC_ENTRY_BATCH); + cfg->sections[i].entries = calloc(CFG_ALLOC_ENTRY_BATCH, + sizeof(struct rte_cfgfile_entry)); if (cfg->sections[i].entries == NULL) goto error1; -- 2.17.1