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 F3671A0471 for ; Tue, 16 Jul 2019 19:28:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B8BB71B9C9; Tue, 16 Jul 2019 19:28:00 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 7821B4CE4 for ; Tue, 16 Jul 2019 19:27:54 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id s1so3464957pgr.2 for ; Tue, 16 Jul 2019 10:27:54 -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 :mime-version:content-transfer-encoding; bh=vRrqhYoOD+XwrMbiwT57dAa2bgdFnmDc6NXKuyewnRk=; b=YcBQjOerHdFSZHmbUzN41G/OD4r+u2xLFf/e60MMnADkkbrklnZpwsxFUFVgnArpaZ Iptips+lxVHZ+BnEOTMnbGjgOpkNImd3Ht0hfiAmZixG2YaqHTZnHWdwso30sDuZpM2L 0EwyTCRFxFEhE9FaP6kBCDLCxxUmYfby7f4Kp0YBsBnFWIWYH1xB2Uveg0qvrF7ZA3pU t+fEfp1MDdd5SskPQg4IE2LXCP6Q+ax4T55CvcF0f9ilQWXW5yZgjqbS0zunVd7LZmGc dYU7NMhUWyOZJDBmtF2M+hOpaFhD9Qg03Pq9wKzROeuYpaosfIeYFAQQIi8zunBp6Ijz ExrA== 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:mime-version:content-transfer-encoding; bh=vRrqhYoOD+XwrMbiwT57dAa2bgdFnmDc6NXKuyewnRk=; b=M7DVwtF17+Hy3hJs9WyPrSduyxc9CazMQI2jTZB+uOCm+wERQ3sLzPn6/2kEDBKTg6 GQZC2EcGP+PBXQZLepUEtA99AnpZlhCzF7CblwGtTtcm/vhca8bEgzi5DQuMjMKea0rs 8lYVvzge0pwfe/7bu6/2efE+QrXtvJ508614UFV9KAv9ykmPKXBnc/m9ZWyEmRFRNUTU i+7I1ViX0/6c7uvxmP9DnhgZazY3HdPpm+6hqDJlWj5OnnfuPWWg8+UIvCY2UEHgqnt1 yLH4VZbIhOiTM0xif+ZVATEu2oE3bH4ibSZ3kuKv77JCWUev5oAa59yOsQSzRxFMKSE5 g5kQ== X-Gm-Message-State: APjAAAUImALSWG4U2E7qnXxfr8ugd94FL9E0MSn99ViuOYxMm192WG4z OE+lk9PIU0keCJDNuUV0m/s= X-Google-Smtp-Source: APXvYqzz2blvcVStUFfiFCgMrKA912OQ9T8vAmz289fW44gm0dY39//ONhhDr+IooEiRhIlfPygCQA== X-Received: by 2002:a17:90a:346c:: with SMTP id o99mr37460729pjb.20.1563298073654; Tue, 16 Jul 2019 10:27:53 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m6sm21173049pfb.151.2019.07.16.10.27.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 10:27:52 -0700 (PDT) From: Stephen Hemminger To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 16 Jul 2019 10:27:41 -0700 Message-Id: <20190716172741.21399-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190716172741.21399-1-stephen@networkplumber.org> References: <20190716172741.21399-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 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 c4b768b6833f..39fec4b82bce 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -275,17 +275,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.20.1