diff options
Diffstat (limited to 'minion/src/util.cpp')
-rw-r--r-- | minion/src/util.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/minion/src/util.cpp b/minion/src/util.cpp index 15cf840..708e47d 100644 --- a/minion/src/util.cpp +++ b/minion/src/util.cpp @@ -3,22 +3,22 @@ namespace util { -auto str_ends_with(const char *str, const char *other_str) noexcept -> bool +auto str_ends_with(const char *target, size_t target_end, const char *other) noexcept + -> bool { - if (str == nullptr || other_str == nullptr) + if (target == nullptr || other == nullptr) { return false; } - auto str_length = strlen(str); - auto other_str_length = strlen(other_str); + const auto other_str_length = strlen(other); - if (other_str_length > str_length) + if (other_str_length > target_end) { return false; } - return strncmp(str + str_length - other_str_length, other_str, other_str_length) == 0; + return strncmp(target + target_end - other_str_length, other, other_str_length) == 0; } void substr(const char *str, const char *end, char *dest) noexcept |