Skip to content

Commit 68d2c0e

Browse files
committed
Use stack for global special value so we don't have to clean it up.
1 parent 6b2de50 commit 68d2c0e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

nbase/nbase_addrset.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,13 @@ struct addrset {
132132

133133
/* Special node pointer to represent "all possible addresses"
134134
* This will be used to represent netmask specifications. */
135-
static struct trie_node *TRIE_NODE_TRUE = NULL;
135+
static struct trie_node g_TRIE_NODE_TRUE = {0};
136+
#define TRIE_NODE_TRUE &g_TRIE_NODE_TRUE
136137

137138
struct addrset *addrset_new()
138139
{
139140
struct addrset *set = (struct addrset *) safe_zalloc(sizeof(struct addrset));
140141
set->head = NULL;
141-
/* We could simply allocate one byte to get a unique address, but this
142-
* feels safer and is not too large. */
143-
if (TRIE_NODE_TRUE == NULL) {
144-
TRIE_NODE_TRUE = (struct trie_node *) safe_zalloc(sizeof(struct trie_node));
145-
}
146142

147143
/* Allocate the first node of the IPv4 trie */
148144
set->trie = (struct trie_node *) safe_zalloc(sizeof(struct trie_node));

0 commit comments

Comments
 (0)