summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2009-12-29 22:49:31 +0100
committerMichal Krol <michal@vmware.com>2009-12-29 22:49:31 +0100
commit7124fa16efe0f8ffb402bcd182f276032bed378d (patch)
tree8ebf82a26ae2c532e473586ea19b4d8131fe7733
parentf7d1689cfa8e3eb2aea4b86031510323b4d13110 (diff)
translate: Fix translate_key_compare().
Sizes of translate keys must also match.
-rw-r--r--src/gallium/auxiliary/translate/translate.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h
index 34526eb0617..1afdf194b31 100644
--- a/src/gallium/auxiliary/translate/translate.h
+++ b/src/gallium/auxiliary/translate/translate.h
@@ -103,8 +103,13 @@ static INLINE int translate_keysize( const struct translate_key *key )
static INLINE int translate_key_compare( const struct translate_key *a,
const struct translate_key *b )
{
- int keysize = translate_keysize(a);
- return memcmp(a, b, keysize);
+ int keysize_a = translate_keysize(a);
+ int keysize_b = translate_keysize(b);
+
+ if (keysize_a != keysize_b) {
+ return keysize_a - keysize_b;
+ }
+ return memcmp(a, b, keysize_a);
}