Skip to content

Commit

Permalink
Partially revert commit 9402f2a
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
stevegrubb committed Sep 7, 2024
1 parent 8d37c61 commit 9df179e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/library/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9df179e

Please sign in to comment.