commit 4583feee5969a11383a24187cff2a47abb02fa47
parent 32b93ef6ea394a8f0c564d4bded2806c7b595696
Author: Paul Riou <paul.riou@protonmail.com>
Date: Thu, 3 Dec 2020 19:17:42 +0000
common: make 'lenient_strcmp' arguments const
Prevents build failures when calling the function with 'const char *'
arguments.
This is also more accurate since the function is not expected to modify
the args.
Diffstat:
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/common/stringop.c b/common/stringop.c
@@ -64,7 +64,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len) {
}
// strcmp that also handles null pointers.
-int lenient_strcmp(char *a, char *b) {
+int lenient_strcmp(const char *a, const char *b) {
if (a == b) {
return 0;
} else if (!a) {
diff --git a/include/stringop.h b/include/stringop.h
@@ -12,7 +12,7 @@ char *lenient_strcat(char *dest, const char *src);
char *lenient_strncat(char *dest, const char *src, size_t len);
// strcmp that also handles null pointers.
-int lenient_strcmp(char *a, char *b);
+int lenient_strcmp(const char *a, const char *b);
// Simply split a string with delims, free with `list_free_items_and_destroy`
list_t *split_string(const char *str, const char *delims);