From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64603 invoked by alias); 26 Sep 2019 08:47:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 64534 invoked by uid 89); 26 Sep 2019 08:47:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1556 X-HELO: mga09.intel.com Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 26 Sep 2019 08:47:33 +0000 Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Sep 2019 01:47:31 -0700 Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by orsmga004.jf.intel.com with ESMTP; 26 Sep 2019 01:47:30 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by IRSMSX101.ger.corp.intel.com (163.33.3.153) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 26 Sep 2019 09:47:29 +0100 Received: from irsmsx104.ger.corp.intel.com ([169.254.5.103]) by IRSMSX156.ger.corp.intel.com ([169.254.3.246]) with mapi id 14.03.0439.000; Thu, 26 Sep 2019 09:47:29 +0100 From: "Metzger, Markus T" To: Andrew Burgess , gdb-patches CC: Simon Marchi , Tom Tromey Subject: RE: [PATCHv3 2/3] gdb: Change a VEC to std::vector in btrace.{c,h} Date: Thu, 26 Sep 2019 08:47:00 -0000 Message-ID: References: <87lfucf2qs.fsf@tromey.com> <6ceaca2e6d37e8bfd913ab787229cbd2d3a7110d.1569455610.git.andrew.burgess@embecosm.com> In-Reply-To: <6ceaca2e6d37e8bfd913ab787229cbd2d3a7110d.1569455610.git.andrew.burgess@embecosm.com> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Return-Path: markus.t.metzger@intel.com Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00509.txt.bz2 Hello Andrew, > @@ -2986,8 +2986,10 @@ btrace_maint_decode_pt (struct btrace_maint_info > *maint, > if (maint_btrace_pt_skip_pad =3D=3D 0 || packet.packet.type !=3D ppt_= pad) > { > packet.errcode =3D pt_errcode (errcode); > - VEC_safe_push (btrace_pt_packet_s, maint->variant.pt.packets, > - &packet); > + if (maint->variant.pt.packets =3D=3D NULL) > + maint->variant.pt.packets > + =3D new std::vector ; > + maint->variant.pt.packets->push_back (packet); We shouldn't do that check inside the loop. I used VEC_safe_push for the r= ealloc aspect. > @@ -3098,11 +3101,13 @@ btrace_maint_update_packets (struct > btrace_thread_info *btinfo, >=20 > #if defined (HAVE_LIBIPT) > case BTRACE_FORMAT_PT: > - if (VEC_empty (btrace_pt_packet_s, btinfo->maint.variant.pt.packet= s)) > + if (btinfo->maint.variant.pt.packets =3D=3D nullptr > + || btinfo->maint.variant.pt.packets->empty ()) > btrace_maint_update_pt_packets (btinfo); Here, I'd check for nullptr in order to allocate the vector and call btrace_maint_update_pt_packets. Afterwards, I'd check for emptiness and de= lete the vector again if there are no packets. We can also leave an empty vector if you prefer that. Regards, Markus. Intel Deutschland GmbH Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Gary Kershaw Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928