Added few more stubs so that control reaches to DestroyDevice().
[mesa.git] / src / util / crc32.c
index f2e01c61e58270f7286fe80b37d011951642b4fc..425046ab5fd02aa25dd24bedf886edb5076e7b24 100644 (file)
@@ -33,6 +33,9 @@
  */
 
 
+#ifdef HAVE_ZLIB
+#include <zlib.h>
+#endif
 #include "crc32.h"
 
 
@@ -114,6 +117,16 @@ util_hash_crc32(const void *data, size_t size)
    const uint8_t *p = data;
    uint32_t crc = 0xffffffff;
  
+#ifdef HAVE_ZLIB
+   /* Prefer zlib's implementation for better performance.
+    * zlib's uInt is always "unsigned int" while size_t can be 64bit.
+    * Since 1.2.9 there's crc32_z that takes size_t, but use the more
+    * available function to avoid build system complications.
+    */
+   if ((uInt)size == size)
+      return ~crc32(0, data, size);
+#endif
+
    while (size--)
       crc = util_crc32_table[(crc ^ *p++) & 0xff] ^ (crc >> 8);