/* 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
#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;
//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);