From 9df179e7c79a6375fd6446a7be9a787655c5776f Mon Sep 17 00:00:00 2001 From: Steve Grubb Date: Sat, 7 Sep 2024 12:12:16 -0400 Subject: [PATCH] Partially revert commit 9402f2ac47195f After doing const analysis, I see it actually writes to the path variable. Instead of strdup, we can use strdupa which allocates on the stack and does not need a free. This should be faster than before. --- src/library/filter.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/library/filter.c b/src/library/filter.c index 1fae22be..c02722f2 100644 --- a/src/library/filter.c +++ b/src/library/filter.c @@ -174,14 +174,15 @@ static void stack_pop_all_reset(stack_t *_stack) // this funtion gets full path and checks it against filter // returns 1 for keeping the file and 0 for dropping it -int filter_check(const char *path) +int filter_check(const char *_path) { - if (path == NULL) { + if (_path == NULL) { msg(LOG_ERR, "filter_check: path is NULL, something is wrong!"); return 0; } filter_t *filter = global_filter; + char *path = strdupa(_path); size_t path_len = strlen(path); size_t offset = 0; // Create a stack to store the filters that need to be checked