[dconf: 1/5] Fix reader on big endian



commit a35852bda37400bb4f7c6ee3a3184dde65fadb1f
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Oct 3 21:10:35 2010 -0400

    Fix reader on big endian
    
    Some of the hashtable code was failing to byteswap properly.

 gvdb-reader.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gvdb-reader.c b/gvdb-reader.c
index 3b77e67..0b1b2ce 100644
--- a/gvdb-reader.c
+++ b/gvdb-reader.c
@@ -34,11 +34,11 @@ struct _GvdbTable {
   gboolean byteswapped;
   gboolean trusted;
 
-  const guint32 *bloom_words;
+  const guint32_le *bloom_words;
   guint32 n_bloom_words;
   guint bloom_shift;
 
-  const guint32 *hash_buckets;
+  const guint32_le *hash_buckets;
   guint32 n_buckets;
 
   struct gvdb_hash_item *hash_items;
@@ -206,7 +206,7 @@ gvdb_table_bloom_filter (GvdbTable *file,
   mask = 1 << (hash_value & 31);
   mask |= 1 << ((hash_value >> file->bloom_shift) & 31);
 
-  return (file->bloom_words[word] & mask) == mask;
+  return (guint32_from_le (file->bloom_words[word]) & mask) == mask;
 }
 
 static gboolean
@@ -262,10 +262,10 @@ gvdb_table_lookup (GvdbTable   *file,
     return NULL;
 
   bucket = hash_value % file->n_buckets;
-  itemno = file->hash_buckets[bucket];
+  itemno = guint32_from_le (file->hash_buckets[bucket]);
 
   if (bucket == file->n_buckets - 1 ||
-      (lastno = file->hash_buckets[bucket + 1]) > file->n_hash_items)
+      (lastno = guint32_from_le(file->hash_buckets[bucket + 1])) > file->n_hash_items)
     lastno = file->n_hash_items;
 
   while G_LIKELY (itemno < lastno)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]