Skip to content

Commit

Permalink
string: use kernel version of strncmp()
Browse files Browse the repository at this point in the history
Signed-off-by: Jason Cooper <[email protected]>
  • Loading branch information
Jason Cooper committed Dec 18, 2013
1 parent 6a5d02f commit c3da82f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ int strlen(const char *str)

int strncmp(const char *stra, const char *strb, int len)
{
int diff=0;
const char *a = stra;
const char *b = strb;

while ((a - stra) < len)
diff += *a++ - *b++;

return diff;
unsigned char c1, c2;

while (len) {
c1 = *stra++;
c2 = *strb++;
if (c1 != c2)
return c1 < c2 ? -1 : 1;
if (!c1)
break;
len--;
}
return 0;
}

void *gethexaddr(const char *str, const char **end)
Expand Down

0 comments on commit c3da82f

Please sign in to comment.