Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp830050pxb; Wed, 22 Sep 2021 14:02:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiLrjelIEZp6WiptjrN65vqiWL2LqzjRqVBmujmZpw0cac4h+tiFm11H5T6hUabhu5Zqb2 X-Received: by 2002:a05:6402:143b:: with SMTP id c27mr1650485edx.224.1632344562946; Wed, 22 Sep 2021 14:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632344562; cv=none; d=google.com; s=arc-20160816; b=DZE4IjciiFQd5jKHFiqA3XeHEyjov7XrFB4DcQP2/KKbH1IIwZduReJblyKcGK07Ev O+oM0ioin8jlRBwfvk65rmAo/K4NPSzlcc3K9J7TkkPgfCB3TCWbR86Jtzd4BzrPFjCE JTqUARdIT7DnRrdMhP3JeCF+trQi4Cr71iM5+OZ428/ZTIvKa8tOj5rwQtg2OXdm2QkC V4w9qY53LgBlJe0QasI24LCQIcubAdBjFmBp2WzmyOcdXpTEQJ3hiaErWp/ZWmkSCQvZ 8DBLAy8jljy/Jf5Dme1bNyReSrmYujqHfvY/zB3SoKr32pViYxRXlEOFisS/NWtxZeXp s33w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WOUQ1umT9EVazlsaxah7aOEpG+BSYoIBiyUBV41kXfo=; b=Y7+Q5SWUxrZdGu33nRW7vDF9Fh1QDqeweU2CxZ7TwVYsQdXnoSRSGNNxLBFD//8C0S Di07lJskn7979hxWS7lg1vpH2lycdGa6CwovXqsKyVVI7NqSNfmWPRLLjHRDs5JQXxe0 dQwJoB0ZvbZu/kSc/eFpi66VDxbcmdsOCwkztaweT69HreHBrCE47jkYUJfVEmrLEqfL jsB8VtfjuOKmL7whemI2AnUwn68lEOLNZQk9zKF5fNQep42RBY/FJXkfIMoHLoI2libb Eq7llWqSr4l8hLn7sCfueHrNJnEG9Wh0emsjnqxXgMOS4vRWpHadppyjKLicvd3QaZre nexw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kpcro+Ss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la20si5128651ejc.3.2021.09.22.14.02.19; Wed, 22 Sep 2021 14:02:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Kpcro+Ss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237778AbhIVVAN (ORCPT + 99 others); Wed, 22 Sep 2021 17:00:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36199 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237592AbhIVVAM (ORCPT ); Wed, 22 Sep 2021 17:00:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632344321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WOUQ1umT9EVazlsaxah7aOEpG+BSYoIBiyUBV41kXfo=; b=Kpcro+Sscw9O0B6Hr0y2Md5ee80QjSTBmxVCXNUuAcnw/UI4RiC2bI6qVYz9LrbmrpcAzx tuS41z55DhWdPIbki5rvsqQ0coWJT1PpGlr4lCOgJOTYYJXNoFrUPu/i6zZGNNXKJN3Z4D 21nqiUOD1nCDMRRzfb8++cxlZ1BU+JU= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-hkLEd8ShMf2o_Eo7pe0XWg-1; Wed, 22 Sep 2021 16:58:38 -0400 X-MC-Unique: hkLEd8ShMf2o_Eo7pe0XWg-1 Received: by mail-wr1-f71.google.com with SMTP id f11-20020adfc98b000000b0015fedc2a8d4so3352806wrh.0 for ; Wed, 22 Sep 2021 13:58:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=WOUQ1umT9EVazlsaxah7aOEpG+BSYoIBiyUBV41kXfo=; b=jJBaSguvBr6DnEKlHh1dmPq9vITt7huWYD0kdSV0yPf9dEYf2KCYmLxyZLR5inAMpT qlauSenyt9CGon9NorIQNjQLH+sRQm6s7hwluKCRUP3qYveeVXc4C1Xyx2ofCt/zcKf7 lh34tDAYmTOJWOxWCC/F4gHCe7nYl6jAZjmfcqbQ8/nyJNGkn/rm9DJF4tHiwJMEaQGU SHU7x+AGBex0oUbMli9meUOhngMbdAMSHLBNuWbYwsuUJwn9lgNBE6S7FvL3DjYsbPNV WuJu2obvD7W5Nkf4J5Yh13Y8o+5b/jr2/lGaOyFmwP+rQJHhmBcIlUblblTgxbfPFqni 7Y6A== X-Gm-Message-State: AOAM533xRUcMWqrF9hVHD9LBu4IWQ3tQ0YI3Kv1zW0MQojGA7WmCJXU/ exAAPS4unNeroztByGqq8L1TiKsLnWr2WvR3HozvMfgo5NhTcxm9nuhvfQoJMfXKqUX9ZubKybi Xbrkfu5QX6e1ujTWebM5FMarK X-Received: by 2002:a1c:403:: with SMTP id 3mr995695wme.161.1632344317359; Wed, 22 Sep 2021 13:58:37 -0700 (PDT) X-Received: by 2002:a1c:403:: with SMTP id 3mr995681wme.161.1632344317199; Wed, 22 Sep 2021 13:58:37 -0700 (PDT) Received: from krava ([83.240.63.48]) by smtp.gmail.com with ESMTPSA id h18sm3250118wrb.33.2021.09.22.13.58.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Sep 2021 13:58:36 -0700 (PDT) Date: Wed, 22 Sep 2021 22:58:33 +0200 From: Jiri Olsa To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Namhyung Kim , linux-kernel@vger.kernel.org, Andi Kleen , Jin Yao , John Garry , Paul Clarke , kajoljain , linux-perf-users@vger.kernel.org, Stephane Eranian , Sandeep Dasgupta Subject: Re: [PATCH v8 5/8] perf metric: Add utilities to work on ids map. Message-ID: References: <20210918063513.2356923-1-irogers@google.com> <20210918063513.2356923-6-irogers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210918063513.2356923-6-irogers@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SNIP > diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c > index adf16bb7571a..34b51ca5e87f 100644 > --- a/tools/perf/util/expr.c > +++ b/tools/perf/util/expr.c > @@ -59,8 +59,48 @@ static bool key_equal(const void *key1, const void *key2, > return !strcmp((const char *)key1, (const char *)key2); > } > > -/* Caller must make sure id is allocated */ > -int expr__add_id(struct expr_parse_ctx *ctx, const char *id) > +struct hashmap *ids__new(void) > +{ > + return hashmap__new(key_hash, key_equal, NULL); > +} > + > +void ids__free(struct hashmap *ids) > +{ > + struct hashmap_entry *cur; > + size_t bkt; > + > + if (ids == NULL) > + return; > + > +#ifdef PARSER_DEBUG > + fprintf(stderr, "freeing ids: "); > + ids__print(ids); > + fprintf(stderr, "\n"); > +#endif hum, is this intended or forgotten debug leftover? jirka > + > + hashmap__for_each_entry(ids, cur, bkt) { > + free((char *)cur->key); > + free(cur->value); > + } > + > + hashmap__free(ids); > +} > + > +void ids__print(struct hashmap *ids) SNIP