minor optimize

This commit is contained in:
Nick Peng
2019-08-16 20:13:09 +08:00
parent 6291c17d6a
commit 87f04571b1
14 changed files with 127 additions and 80 deletions

View File

@@ -390,6 +390,10 @@ art_leaf* art_maximum(art_tree *t) {
static art_leaf* make_leaf(const unsigned char *key, int key_len, void *value) {
art_leaf *l = (art_leaf*)calloc(1, sizeof(art_leaf)+key_len+1);
if (l == NULL) {
return NULL;
}
l->value = value;
l->key_len = key_len;
memcpy(l->key, key, key_len);

View File

@@ -281,7 +281,7 @@ static radix_node_t
*radix_search_best2(radix_tree_t *radix, prefix_t *prefix, int inclusive)
{
radix_node_t *node;
radix_node_t *stack[RADIX_MAXBITS + 1];
radix_node_t *stack[RADIX_MAXBITS + 1] = {0};
unsigned char *addr;
unsigned int bitlen;
int cnt = 0;