Commit c63bd323 authored by Max Kellermann's avatar Max Kellermann

util/StringCompare: use std::memcmp()

parent 55db7105
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include "StringCompare.hxx" #include "StringCompare.hxx"
#include <string.h> #include <cstring>
bool bool
StringEndsWith(const char *haystack, const char *needle) noexcept StringEndsWith(const char *haystack, const char *needle) noexcept
...@@ -38,8 +38,8 @@ StringEndsWith(const char *haystack, const char *needle) noexcept ...@@ -38,8 +38,8 @@ StringEndsWith(const char *haystack, const char *needle) noexcept
const size_t needle_length = StringLength(needle); const size_t needle_length = StringLength(needle);
return haystack_length >= needle_length && return haystack_length >= needle_length &&
memcmp(haystack + haystack_length - needle_length, std::memcmp(haystack + haystack_length - needle_length,
needle, needle_length) == 0; needle, needle_length) == 0;
} }
bool bool
...@@ -63,7 +63,7 @@ FindStringSuffix(const char *p, const char *suffix) noexcept ...@@ -63,7 +63,7 @@ FindStringSuffix(const char *p, const char *suffix) noexcept
return nullptr; return nullptr;
const char *q = p + p_length - suffix_length; const char *q = p + p_length - suffix_length;
return memcmp(q, suffix, suffix_length) == 0 return std::memcmp(q, suffix, suffix_length) == 0
? q ? q
: nullptr; : nullptr;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment