Use strdup() instead of fixed PATH_MAX buffer for storing paths to not
waste memory.
Suggested-by: Ian Rogers <irogers@google.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: James Clark <james.clark@linaro.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
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,
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;
rb_node);
rb_erase(node, root);
+ free(ts->path);
free(ts);
}
}