aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorToni <matzeton@googlemail.com>2024-05-08 11:38:53 +0200
committerGitHub <noreply@github.com>2024-05-08 11:38:53 +0200
commite9dc035c5ca8e8e9012c76d5e2bdb9c085d6664a (patch)
treea348f5ceafba2ef93f609f89b2f0c4d47695cd00 /example/ndpiReader.c
parent2b4e2f9c9a5befc011c5743fee29dafa273ad6cb (diff)
Added optimized memmem/strlcpy version (#2424)
* credits goes to Vladimir Gavrilov Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 54bf00208..60d13f919 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -5625,35 +5625,35 @@ void strtonumUnitTest() {
void strlcpyUnitTest() {
// Test empty string
char dst_empty[10] = "";
- assert(ndpi_strlcpy(dst_empty, "", sizeof(dst_empty)) == 0);
+ assert(ndpi_strlcpy(dst_empty, "", sizeof(dst_empty), 0) == 0);
assert(dst_empty[0] == '\0');
// Basic copy test
char dst1[10] = "";
- assert(ndpi_strlcpy(dst1, "abc", sizeof(dst1)) == 3);
+ assert(ndpi_strlcpy(dst1, "abc", sizeof(dst1), 3) == 3);
assert(strcmp(dst1, "abc") == 0);
// Test with dst_len smaller than src_len
char dst2[4] = "";
- assert(ndpi_strlcpy(dst2, "abcdef", sizeof(dst2)) == 6);
+ assert(ndpi_strlcpy(dst2, "abcdef", sizeof(dst2), 6) == 6);
assert(strcmp(dst2, "abc") == 0); // Should truncate "abcdef" to "abc"
// Test with dst_len bigger than src_len
char dst3[10] = "";
- assert(ndpi_strlcpy(dst3, "abc", sizeof(dst3)) == 3);
+ assert(ndpi_strlcpy(dst3, "abc", sizeof(dst3), 3) == 3);
assert(strcmp(dst3, "abc") == 0);
// Test with dst_len equal to 1 (only null terminator should be copied)
char dst4[1];
- assert(ndpi_strlcpy(dst4, "abc", sizeof(dst4)) == 3);
+ assert(ndpi_strlcpy(dst4, "abc", sizeof(dst4), 3) == 3);
assert(dst4[0] == '\0'); // Should only contain the null terminator
// Test with NULL source, expecting return value to be 0
char dst5[10];
- assert(ndpi_strlcpy(dst5, NULL, sizeof(dst5)) == 0);
+ assert(ndpi_strlcpy(dst5, NULL, sizeof(dst5), 0) == 0);
// Test with NULL destination, should also return 0 without crashing
- assert(ndpi_strlcpy(NULL, "abc", sizeof(dst5)) == 0);
+ assert(ndpi_strlcpy(NULL, "abc", sizeof(dst5), 3) == 0);
}
/* *********************************************** */