libhfuzz/memorycmp: use __builtin_tolower instead of tolower
-#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
@@ -27,7 +26,8 @@ static inline int HF_strcmp(const char* s1, const char* s2, uintptr_t addr) {
static inline int HF_strcasecmp(const char* s1, const char* s2, uintptr_t addr) {
unsigned int v = 0;
- for (size_t i = 0; tolower((unsigned char)s1[i]) == tolower((unsigned char)s2[i]); i++) {
+ for (size_t i = 0;
+ __builtin_tolower((unsigned char)s1[i]) == __builtin_tolower((unsigned char)s2[i]); i++) {
if (s1[i] == '\0' || s2[i] == '\0') {
break;
}
@@ -38,10 +38,6 @@ static inline int HF_strcasecmp(const char* s1, const char* s2, uintptr_t addr)
}
static inline int HF_strncmp(const char* s1, const char* s2, size_t n, uintptr_t addr) {
- if (n == 0) {
- return __builtin_strncmp(s1, s2, n);
- }
-
unsigned int v = 0;
for (size_t i = 0; i < n; i++) {
if (s1[i] != s2[i]) {
@@ -59,7 +55,7 @@ static inline int HF_strncmp(const char* s1, const char* s2, size_t n, uintptr_t
static inline int HF_strncasecmp(const char* s1, const char* s2, size_t n, uintptr_t addr) {
unsigned int v = 0;
for (size_t i = 0; i < n; i++) {
- if (tolower((unsigned char)s1[i]) != tolower((unsigned char)s2[i])) {
+ if (__builtin_tolower((unsigned char)s1[i]) != __builtin_tolower((unsigned char)s2[i])) {
break;
}
if (s1[i] == '\0' || s2[i] == '\0') {
