Commit 4b5dafe6 authored by James Clark's avatar James Clark Committed by Namhyung Kim
Browse files

perf tests: use strdup() in "Object code reading"



Use strdup() instead of fixed PATH_MAX buffer for storing paths to not
waste memory.

Suggested-by: default avatarIan Rogers <irogers@google.com>
Reviewed-by: default avatarIan Rogers <irogers@google.com>
Signed-off-by: default avatarJames Clark <james.clark@linaro.org>
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
parent 3a866087
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@
struct tested_section {
	struct rb_node rb_node;
	u64 addr;
	char path[PATH_MAX];
	char *path;
};

static bool tested_code_insert_or_exists(const char *path, u64 addr,
@@ -79,7 +79,11 @@ static bool tested_code_insert_or_exists(const char *path, u64 addr,
		return true;

	data->addr = addr;
	strlcpy(data->path, path, sizeof(data->path));
	data->path = strdup(path);
	if (!data->path) {
		free(data);
		return true;
	}
	rb_link_node(&data->rb_node, parent, node);
	rb_insert_color(&data->rb_node, tested_sections);
	return false;
@@ -94,6 +98,7 @@ static void tested_sections__free(struct rb_root *root)
						     rb_node);

		rb_erase(node, root);
		free(ts->path);
		free(ts);
	}
}