diff options
author | eadler <eadler@FreeBSD.org> | 2011-11-22 00:07:53 +0000 |
---|---|---|
committer | eadler <eadler@FreeBSD.org> | 2011-11-22 00:07:53 +0000 |
commit | 7eb95f50e380e785a18aaee6734807ee6db226a6 (patch) | |
tree | abcaedad17a9a120ce91c83c2e7ca0fda8f47c2d /lib/libc/string/strncmp.c | |
parent | 3be48b6d59eed7d8eadd7974014c5cf08eb38e9a (diff) | |
download | FreeBSD-src-7eb95f50e380e785a18aaee6734807ee6db226a6.zip FreeBSD-src-7eb95f50e380e785a18aaee6734807ee6db226a6.tar.gz |
- add check for pointer equality prior to performing the O(n) pass
- while here change 's' to 's1' in strcoll
Submitted by: eadler@
Reviewed by: theraven@
Approved by: brooks@
MFC after: 2 weeks
Diffstat (limited to 'lib/libc/string/strncmp.c')
-rw-r--r-- | lib/libc/string/strncmp.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc/string/strncmp.c b/lib/libc/string/strncmp.c index 5bc3d5e..46db3f9 100644 --- a/lib/libc/string/strncmp.c +++ b/lib/libc/string/strncmp.c @@ -39,8 +39,9 @@ int strncmp(const char *s1, const char *s2, size_t n) { - if (n == 0) + if ((n == 0) | (s1 == s2)) return (0); + do { if (*s1 != *s2++) return (*(const unsigned char *)s1 - |