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 B551DA0471 for ; Thu, 18 Jul 2019 02:48:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 062111B952; Thu, 18 Jul 2019 02:48:37 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 69CF13977 for ; Thu, 18 Jul 2019 02:48:32 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id t132so11982441pgb.9 for ; Wed, 17 Jul 2019 17:48:32 -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=TK3sleuApVQSR7Ot12jPA+s4R6dJqU06F9dYryJScJVhImzomWX65f+2bDHyl7vr2x Lnn1m24AB3E5qZ+PcXS13TtJj1jPVpcBipZDNnw6QK4YA1HyNuAo2sIVyGpO9i0F5Sig +VhTB29JpcXT5IrAIs07qI2bpYycm0dVj7ovvWJIE2m4Fpfz8wAET3DdZkA0Ic6rRSm8 5fuZfrVFEBGHQLzpCFjV5V7HCG/FowzPsn26gEIoHxqVtQtYED1mIXLSSWp/n3dVHAIJ 4TJANLT8ZxbH/IEkF3dwUaJsHWoyT49vo6mfLA5b1yzaffIEbbERyzUpEV61UTWcd+aA dQRg== 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=ECd4nQFsYX1PZ8rlIvmR9COXTrD85xbUkdlkG5IjBn5oLcIfbKUr3G0Eq14KlWMZcv TlHg0yujzwJgruIPIHDS6BJAhJFhu3FQ6ArXJmnwHHQils9+w9AcPlL53gwMS5R733WK h19QS0/LM80i0pmJkiKvW/7E6iQYIwsNkNpQjE3aRbLX3cwws5Y5/kAG3g6m528ak2bx HTKb1btFNrJyIjSAXeuiJjbUwYv7/qR/hkdxtzOqvMgz5G049/RXxvLKTqblVYLycljJ yzpfpibuEkYAT9IqQf2ofLEehiqgunLplVVvRbKMh4OHTeyZ37mK6+h5ByZcnIMuFPAI Rd0A== X-Gm-Message-State: APjAAAV4No2tc9C0g4bR5EPmqaBtPYw3hXNudZQxzn84/eWgxhlYsquF sRuGFpm9SHlAS1jmvUMoXW69vNIR X-Google-Smtp-Source: APXvYqztvQuYQjB2TrTqIKeRPd+T05rH7ZCvT5/+KpmVDQLsHREMRRk6yW9HAfQ8ZWoz3C+UDAI8BA== X-Received: by 2002:a63:61c6:: with SMTP id v189mr38348241pgb.36.1563410911304; Wed, 17 Jul 2019 17:48:31 -0700 (PDT) Received: from xps13.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 131sm30459808pfx.57.2019.07.17.17.48.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 17:48:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 17 Jul 2019 17:48:22 -0700 Message-Id: <20190718004822.25431-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190718004822.25431-1-stephen@networkplumber.org> References: <20190716172741.21399-1-stephen@networkplumber.org> <20190718004822.25431-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 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