diff options
Diffstat (limited to 'tools/perf/util/expr.c')
| -rw-r--r-- | tools/perf/util/expr.c | 36 | 
1 files changed, 15 insertions, 21 deletions
| diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index aaacf514dc09..2f05ecdcfe9a 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -46,7 +46,7 @@ struct expr_id_data {  	} kind;  }; -static size_t key_hash(const void *key, void *ctx __maybe_unused) +static size_t key_hash(long key, void *ctx __maybe_unused)  {  	const char *str = (const char *)key;  	size_t hash = 0; @@ -59,8 +59,7 @@ static size_t key_hash(const void *key, void *ctx __maybe_unused)  	return hash;  } -static bool key_equal(const void *key1, const void *key2, -		    void *ctx __maybe_unused) +static bool key_equal(long key1, long key2, void *ctx __maybe_unused)  {  	return !strcmp((const char *)key1, (const char *)key2);  } @@ -84,8 +83,8 @@ void ids__free(struct hashmap *ids)  		return;  	hashmap__for_each_entry(ids, cur, bkt) { -		free((char *)cur->key); -		free(cur->value); +		free((void *)cur->pkey); +		free((void *)cur->pvalue);  	}  	hashmap__free(ids); @@ -97,8 +96,7 @@ int ids__insert(struct hashmap *ids, const char *id)  	char *old_key = NULL;  	int ret; -	ret = hashmap__set(ids, id, data_ptr, -			   (const void **)&old_key, (void **)&old_data); +	ret = hashmap__set(ids, id, data_ptr, &old_key, &old_data);  	if (ret)  		free(data_ptr);  	free(old_key); @@ -127,8 +125,7 @@ struct hashmap *ids__union(struct hashmap *ids1, struct hashmap *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); +		ret = hashmap__set(ids1, cur->key, cur->value, &old_key, &old_data);  		free(old_key);  		free(old_data); @@ -169,8 +166,7 @@ int expr__add_id_val_source_count(struct expr_parse_ctx *ctx, const char *id,  	data_ptr->val.source_count = source_count;  	data_ptr->kind = EXPR_ID_DATA__VALUE; -	ret = hashmap__set(ctx->ids, id, data_ptr, -			   (const void **)&old_key, (void **)&old_data); +	ret = hashmap__set(ctx->ids, id, data_ptr, &old_key, &old_data);  	if (ret)  		free(data_ptr);  	free(old_key); @@ -205,8 +201,7 @@ int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)  	data_ptr->ref.metric_expr = ref->metric_expr;  	data_ptr->kind = EXPR_ID_DATA__REF; -	ret = hashmap__set(ctx->ids, name, data_ptr, -			   (const void **)&old_key, (void **)&old_data); +	ret = hashmap__set(ctx->ids, name, data_ptr, &old_key, &old_data);  	if (ret)  		free(data_ptr); @@ -221,7 +216,7 @@ int expr__add_ref(struct expr_parse_ctx *ctx, struct metric_ref *ref)  int expr__get_id(struct expr_parse_ctx *ctx, const char *id,  		 struct expr_id_data **data)  { -	return hashmap__find(ctx->ids, id, (void **)data) ? 0 : -1; +	return hashmap__find(ctx->ids, id, data) ? 0 : -1;  }  bool expr__subset_of_ids(struct expr_parse_ctx *haystack, @@ -232,7 +227,7 @@ bool expr__subset_of_ids(struct expr_parse_ctx *haystack,  	struct expr_id_data *data;  	hashmap__for_each_entry(needles->ids, cur, bkt) { -		if (expr__get_id(haystack, cur->key, &data)) +		if (expr__get_id(haystack, cur->pkey, &data))  			return false;  	}  	return true; @@ -282,8 +277,7 @@ void expr__del_id(struct expr_parse_ctx *ctx, const char *id)  	struct expr_id_data *old_val = NULL;  	char *old_key = NULL; -	hashmap__delete(ctx->ids, id, -			(const void **)&old_key, (void **)&old_val); +	hashmap__delete(ctx->ids, id, &old_key, &old_val);  	free(old_key);  	free(old_val);  } @@ -314,8 +308,8 @@ void expr__ctx_clear(struct expr_parse_ctx *ctx)  	size_t bkt;  	hashmap__for_each_entry(ctx->ids, cur, bkt) { -		free((char *)cur->key); -		free(cur->value); +		free((void *)cur->pkey); +		free(cur->pvalue);  	}  	hashmap__clear(ctx->ids);  } @@ -330,8 +324,8 @@ void expr__ctx_free(struct expr_parse_ctx *ctx)  	free(ctx->sctx.user_requested_cpu_list);  	hashmap__for_each_entry(ctx->ids, cur, bkt) { -		free((char *)cur->key); -		free(cur->value); +		free((void *)cur->pkey); +		free(cur->pvalue);  	}  	hashmap__free(ctx->ids);  	free(ctx); |