[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YUuZNJjphZBHOAAA@krava>
Date: Wed, 22 Sep 2021 22:59:32 +0200
From: Jiri Olsa <jolsa@...hat.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
Jin Yao <yao.jin@...ux.intel.com>,
John Garry <john.garry@...wei.com>,
Paul Clarke <pc@...ibm.com>, kajoljain <kjain@...ux.ibm.com>,
linux-perf-users@...r.kernel.org,
Stephane Eranian <eranian@...gle.com>,
Sandeep Dasgupta <sdasgup@...gle.com>
Subject: Re: [PATCH v8 5/8] perf metric: Add utilities to work on ids map.
On Fri, Sep 17, 2021 at 11:35:10PM -0700, Ian Rogers wrote:
SNIP
>
> +struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *ids2)
> +{
> + size_t bkt;
> + struct hashmap_entry *cur;
> + int ret;
> + struct expr_id_data *old_data = NULL;
> + char *old_key = NULL;
> +
> + if (!ids1)
> + return ids2;
> +
> + if (!ids2)
> + return ids1;
> +
> + if (hashmap__size(ids1) < hashmap__size(ids2)) {
> + struct hashmap *tmp = ids1;
> +
> + ids1 = ids2;
> + ids2 = tmp;
> + }
> + hashmap__for_each_entry(ids2, cur, bkt) {
> + ret = hashmap__set(ids1, cur->key, cur->value,
> + (const void **)&old_key, (void **)&old_data);
> + free(old_key);
> + free(old_data);
> +
> + if (ret)
> + break;
should we return NULL in here?
jirka
> + }
> + hashmap__free(ids2);
> + return ids1;
> +}
> +
> +/* Caller must make sure id is allocated */
> +int expr__add_id(struct expr_parse_ctx *ctx, const char *id)
> +{
> + return ids__insert(ctx->ids, id, ctx->parent);
> +}
> +
SNIP
Powered by blists - more mailing lists