Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimenezrick committed Oct 8, 2011
1 parent 0b8ebd0 commit decb2f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 3 additions & 0 deletions compile.sh
@@ -0,0 +1,3 @@
#!/bin/sh

gcc -std=c99 -Wall -c critbit_tree.c
9 changes: 2 additions & 7 deletions critbit_tree.c
Expand Up @@ -17,7 +17,7 @@ bool cbtree_contain(critbit_tree_t *tree, const uint8_t *data, size_t len);

bool cbtree_contain_str(critbit_tree_t *tree, const char *str)
{
return cbtree_contain(tree, (uint8_t *) str, 0);
return cbtree_contain(tree, (uint8_t *) str, strlen(str));
}

bool cbtree_contain(critbit_tree_t *tree, const uint8_t *data, size_t len)
Expand All @@ -26,8 +26,6 @@ bool cbtree_contain(critbit_tree_t *tree, const uint8_t *data, size_t len)

if (!p)
return false;
if (!len)
len = strlen((char *) data);

while ((intptr_t) p & 1) {
critbit_node_t *q = p - 1;
Expand All @@ -40,8 +38,5 @@ bool cbtree_contain(critbit_tree_t *tree, const uint8_t *data, size_t len)
p = q->child[dir];
}

if (len)
return memcmp(data, p, len);
else
return strcmp((char *) data, (char *) p) == 0;
return memcmp(data, p, len);
}

0 comments on commit decb2f0

Please sign in to comment.