translate: Fix translate_key_compare().
[mesa.git] / src / gallium / auxiliary / translate / translate.h
index 34526eb0617ae6a366c87fb2e8915fb9c1ca5692..1afdf194b319e3fbe9f21852039949bcf987623c 100644 (file)
@@ -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);
 }