Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ndpi_memmem: optimized, fixed bug, added tests #2499

Merged
merged 1 commit into from
Jul 15, 2024
Merged

ndpi_memmem: optimized, fixed bug, added tests #2499

merged 1 commit into from
Jul 15, 2024

Conversation

pasabanov
Copy link
Contributor

@pasabanov pasabanov commented Jul 14, 2024

Please sign (check) the below before submitting the Pull Request:

#2378 #2424 #2494

Describe changes:

Similar changes to this PR (#2494).

  1. Made the function ndpi_memmem return haystack when needle_len == 0 instead of NULL. This is more logical and aligns with the default behavior for standard implementations, such as GNU libc and FreeBSD libc.
  2. Optimized performance by replacing the variable haystack_end with the variable end_of_search, which reduces the number of checks during the search.
  3. Added unit tests for the function ndpi_memmem.

Copy link
Collaborator

@IvanNardi IvanNardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; I particularly appreciated the tests!

@IvanNardi IvanNardi merged commit 2f66a6a into ntop:dev Jul 15, 2024
35 checks passed
@IvanNardi
Copy link
Collaborator

Thank you

@IvanNardi
Copy link
Collaborator

@pasabanov, @0xA50C1A1: might it be possible to implement ndpi_strnstr() using ndpi_memmem()? They are basically the same function....

@0xA50C1A1
Copy link
Contributor

@pasabanov, @0xA50C1A1: might it be possible to implement ndpi_strnstr() using ndpi_memmem()? They are basically the same function....

That's a great idea. I created a PR with a refactored function. #2500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants