Mesa (instanced-arrays): translate: Fix translate_key_compare().

Michał Król michal at kemper.freedesktop.org
Wed Dec 30 05:23:44 PST 2009


Module: Mesa
Branch: instanced-arrays
Commit: 7124fa16efe0f8ffb402bcd182f276032bed378d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7124fa16efe0f8ffb402bcd182f276032bed378d

Author: Michal Krol <michal at vmware.com>
Date:   Tue Dec 29 22:49:31 2009 +0100

translate: Fix translate_key_compare().

Sizes of translate keys must also match.

---

 src/gallium/auxiliary/translate/translate.h |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h
index 34526eb..1afdf19 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);
 }
 
 



More information about the mesa-commit mailing list