From 68d2c0e9605763e70e97d4844e27234e2710f4a0 Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 27 Apr 2021 19:22:10 +0000 Subject: [PATCH] Use stack for global special value so we don't have to clean it up. --- nbase/nbase_addrset.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nbase/nbase_addrset.c b/nbase/nbase_addrset.c index de14a0de3..9efb6d3eb 100644 --- a/nbase/nbase_addrset.c +++ b/nbase/nbase_addrset.c @@ -132,17 +132,13 @@ struct addrset { /* Special node pointer to represent "all possible addresses" * This will be used to represent netmask specifications. */ -static struct trie_node *TRIE_NODE_TRUE = NULL; +static struct trie_node g_TRIE_NODE_TRUE = {0}; +#define TRIE_NODE_TRUE &g_TRIE_NODE_TRUE struct addrset *addrset_new() { struct addrset *set = (struct addrset *) safe_zalloc(sizeof(struct addrset)); set->head = NULL; - /* We could simply allocate one byte to get a unique address, but this - * feels safer and is not too large. */ - if (TRIE_NODE_TRUE == NULL) { - TRIE_NODE_TRUE = (struct trie_node *) safe_zalloc(sizeof(struct trie_node)); - } /* Allocate the first node of the IPv4 trie */ set->trie = (struct trie_node *) safe_zalloc(sizeof(struct trie_node));