From nobody Tue Feb 10 07:41:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506036936480789.453157038288; Thu, 21 Sep 2017 16:35:36 -0700 (PDT) Received: from localhost ([::1]:55939 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvB0H-0003jN-IG for importer@patchew.org; Thu, 21 Sep 2017 19:35:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvAiF-0004bl-O0 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvAiE-00043v-OC for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:55 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:35973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvAiE-00041Y-ID for qemu-devel@nongnu.org; Thu, 21 Sep 2017 19:16:54 -0400 Received: by mail-wm0-x241.google.com with SMTP id r136so6437005wmf.3 for ; Thu, 21 Sep 2017 16:16:54 -0700 (PDT) Received: from 640k.lan (dynamic-adsl-78-12-246-117.clienti.tiscali.it. [78.12.246.117]) by smtp.gmail.com with ESMTPSA id u186sm2596278wmd.19.2017.09.21.16.16.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 16:16:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Y5ObZd/gjJRAvi6vvPYuTdy7Fi+koNOrytR2HUeWDc=; b=Px/S9VQGLDu6js0Jq7hiD1+OfAPwkf2Mx22AoOnAzxjDZJD6Qa0FBYVEIhPia7OIgV gGze9DCrhrFv79VFYKn2Fwy6MYeUbIt+SRogcEafHg99kmA2ff75FuXXrB6fLOouyJ4H bHEWpztBc05iaeZy/YBR9r7QdeiRHxMUtLmfxs3+hbP3Ad2O2+g/APaDPfJsO8fPet85 1ti9DFeZAQkocNS/7CxFVXGu3Ypd4dFpOSpLvxFsUiKnhy95RB/koI4eVsvxmddQHv3j oATbeymhaAmaT7V+yTOtOeosQlLAAareTOscvc2Bsk0LJ6mIlkl4tzbXwPeZ70+yJ9zi twjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=0Y5ObZd/gjJRAvi6vvPYuTdy7Fi+koNOrytR2HUeWDc=; b=qG8DW8Z2oqEpO4/PHGj8X4CFXeBnAZYSWKacRQDBMydP8ucuevoBanGCpeylgBsNMA p3xqBlFhqN25vQ1Oo7e+V8kt7rQbXaJuBuZQ6ybxfbWGhGE9Tycc23jlPaF0HGHpUm+Q 7aodJxnGnA94xyuR+OhYFh3cCKl7eNzqCoM70qvv2/Ql0Y1s8Q8ETGLJJx5fpr0ab7wK Q7uD1NafBdW7s6EQULcFlI8bX9QtUpujH+GpfmxSBCz2VRJ/7tVv13McwFDN9AFEbJsA HzFFnsZ9wcAcmQRX6C9HljUznvMLomKacT8q3Djah2ljK/NU5Inc2j5A6s5pat9IER6d NKkg== X-Gm-Message-State: AHPjjUgxpAd0zvljytYBz7AY957NV3tHPYX2qNl9jtAldUe8F54ZznnR Rufeou7Fk8SSlyphqbxIKrkq2/pD X-Google-Smtp-Source: AOwi7QDcSzp0tkDt7gUnh/SZHVD//eIHSxCD2pw4qJwOczqkJx6O4mU/OYzpAiwETdC+xnBe/GbuQw== X-Received: by 10.28.165.136 with SMTP id o130mr2283282wme.107.1506035813261; Thu, 21 Sep 2017 16:16:53 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 22 Sep 2017 01:16:16 +0200 Message-Id: <1506035800-30509-9-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> References: <1506035800-30509-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PULL 08/32] memory: Move FlatView allocation to a helper X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Kardashevskiy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alexey Kardashevskiy This moves a FlatView allocation and initialization to a helper. While we are nere, replace g_new with g_new0 to not to bother if we add new fields in the future. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy Message-Id: <20170921085110.25598-4-aik@ozlabs.ru> Signed-off-by: Paolo Bonzini --- memory.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/memory.c b/memory.c index 3241e44..eec668e 100644 --- a/memory.c +++ b/memory.c @@ -258,12 +258,14 @@ static bool flatrange_equal(FlatRange *a, FlatRange *= b) && a->readonly =3D=3D b->readonly; } =20 -static void flatview_init(FlatView *view) +static FlatView *flatview_new(void) { + FlatView *view; + + view =3D g_new0(FlatView, 1); view->ref =3D 1; - view->ranges =3D NULL; - view->nr =3D 0; - view->nr_allocated =3D 0; + + return view; } =20 /* Insert a range into a given position. Caller is responsible for mainta= ining @@ -707,8 +709,7 @@ static FlatView *generate_memory_topology(MemoryRegion = *mr) { FlatView *view; =20 - view =3D g_new(FlatView, 1); - flatview_init(view); + view =3D flatview_new(); =20 if (mr) { render_memory_region(view, mr, int128_zero(), @@ -2629,8 +2630,7 @@ void address_space_init(AddressSpace *as, MemoryRegio= n *root, const char *name) as->ref_count =3D 1; as->root =3D root; as->malloced =3D false; - as->current_map =3D g_new(FlatView, 1); - flatview_init(as->current_map); + as->current_map =3D flatview_new(); as->ioeventfd_nb =3D 0; as->ioeventfds =3D NULL; QTAILQ_INIT(&as->listeners); --=20 1.8.3.1