Replace some strncmp's with memcmp

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2014-10-18 13:23:53 +03:00
parent a4cc119bf5
commit f774f819d6
2 changed files with 4 additions and 4 deletions

View File

@ -115,13 +115,13 @@ resolve_name(const char *filename, enum resolve_name_direction direction,
s++;
if (direction == LEFT_TO_RIGHT) {
if (left_len == name_len && strncmp(left, name, left_len) == 0) {
if (left_len == name_len && memcmp(left, name, left_len) == 0) {
match = strndup(right, right_len);
break;
}
}
else if (direction == RIGHT_TO_LEFT) {
if (right_len == name_len && strncmp(right, name, right_len) == 0) {
if (right_len == name_len && memcmp(right, name, right_len) == 0) {
match = strndup(left, left_len);
break;
}

View File

@ -34,13 +34,13 @@ typedef darray(struct sval) darray_sval;
static inline bool
svaleq(struct sval s1, struct sval s2)
{
return s1.len == s2.len && strncmp(s1.start, s2.start, s1.len) == 0;
return s1.len == s2.len && memcmp(s1.start, s2.start, s1.len) == 0;
}
static inline bool
svaleq_prefix(struct sval s1, struct sval s2)
{
return s1.len <= s2.len && strncmp(s1.start, s2.start, s1.len) == 0;
return s1.len <= s2.len && memcmp(s1.start, s2.start, s1.len) == 0;
}
struct scanner {