mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
Fix bug in new bcmp() function
Was revealed by ndk-build, ie, on a system with HAVE_BCMP false
This commit is contained in:
parent
f8386d5aed
commit
630c7cd57d
10
os.h
10
os.h
@ -70,8 +70,14 @@ __SERVALDNA_OS_INLINE void bcopy(void *src, void *dst, size_t len) {
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_BCMP
|
||||
__SERVALDNA_OS_INLINE int bcmp(const void *s1, const void *s2) {
|
||||
return memcmp(s1, s2);
|
||||
__SERVALDNA_OS_INLINE int bcmp(const void *s1, const void *s2, size_t n) {
|
||||
// bcmp() is only an equality test, not an order test, so its return value
|
||||
// is not specified as negative or positive, only non-zero. Hoewver
|
||||
// memcmp() is an order test. We deliberately discard negative return
|
||||
// values from memcmp(), to avoid misleading developers into assuming that
|
||||
// bcmp() is an ordering operator and writing code that depends on that,
|
||||
// which of course would fail on platforms with a native bcmp() function.
|
||||
return memcmp(s1, s2, n) != 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user