]> git.ozlabs.org Git - ccan/blobdiff - ccan/stringmap/stringmap.c
talloc: spelling fix.
[ccan] / ccan / stringmap / stringmap.c
index 7380e4e1e82b0fc0575c98ad3562bb9cd6ea1650..364e2a4881519b2d2af1f89dd3dedb6dd08d8ceb 100644 (file)
@@ -29,7 +29,7 @@
 /* This is a heavily modified version of the Patricia tree implementation
    in PCC at http://pcc.zentus.com/cgi-bin/cvsweb.cgi/cc/cpp/cpp.c?rev=1.96 */
 
-#include "stringmap.h"
+#include <ccan/stringmap/stringmap.h>
 
 //#define CONSISTENCY_CHECK
 
@@ -39,7 +39,7 @@
 #define assert(...) do {} while(0)
 #endif
 
-#define PEEK_BIT(key, bit)             ((key[bit >> 3] >> (bit & 7)) & 1)
+#define PEEK_BIT(key, bit)             ((key[bit >> 3] >> (~bit & 7)) & 1)
 
 struct stringmap_node {
        uint32_t left_is_leaf:1, right_is_leaf:1, bitno:30;
@@ -155,8 +155,8 @@ void *stringmap_lookup_real(struct stringmap *t, const char *key, size_t len, in
                        
                        //advance cix to the first differing bit
                        ix = *m ^ *k;
-                       while ((ix & 1) == 0)
-                               ix >>= 1, cix++;
+                       while ((ix & 128) == 0)
+                               ix <<= 1, cix++;
                        
                        //choose left/right based on the differing bit
                        bit = PEEK_BIT(key, cix);