lkml.org 
[lkml]   [2021]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v8 5/8] perf metric: Add utilities to work on ids map.
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

\
 
 \ /
  Last update: 2021-09-22 22:59    [W:0.085 / U:1.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site