diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/clock.c | 2 | ||||
-rw-r--r-- | src/lib/clock.h | 2 | ||||
-rw-r--r-- | src/lib/clock.hh | 4 | ||||
-rw-r--r-- | src/lib/clock.lua | 2 | ||||
-rw-r--r-- | src/lib/getopt.lua | 2 | ||||
-rw-r--r-- | src/lib/ip.lua | 2 | ||||
-rw-r--r-- | src/lib/parseconf.lua | 2 | ||||
-rw-r--r-- | src/lib/trie.c | 30 |
8 files changed, 25 insertions, 21 deletions
diff --git a/src/lib/clock.c b/src/lib/clock.c index a5889ef..9e1c2a3 100644 --- a/src/lib/clock.c +++ b/src/lib/clock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * This file is part of dnsjit. diff --git a/src/lib/clock.h b/src/lib/clock.h index b00d4fe..45120d9 100644 --- a/src/lib/clock.h +++ b/src/lib/clock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * This file is part of dnsjit. diff --git a/src/lib/clock.hh b/src/lib/clock.hh index f69a1bc..77e1308 100644 --- a/src/lib/clock.hh +++ b/src/lib/clock.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2023, OARC, Inc. + * Copyright (c) 2018-2024 OARC, Inc. * All rights reserved. * * This file is part of dnsjit. @@ -18,7 +18,7 @@ * along with dnsjit. If not, see <http://www.gnu.org/licenses/>. */ -//lua:require("dnsjit.core.timespec_h") +// lua:require("dnsjit.core.timespec_h") typedef enum lib_clock_clkid { LIB_CLOCK_REALTIME, diff --git a/src/lib/clock.lua b/src/lib/clock.lua index cdad30e..74c1857 100644 --- a/src/lib/clock.lua +++ b/src/lib/clock.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2018-2023, OARC, Inc. +-- Copyright (c) 2018-2024 OARC, Inc. -- All rights reserved. -- -- This file is part of dnsjit. diff --git a/src/lib/getopt.lua b/src/lib/getopt.lua index 416a658..0622dda 100644 --- a/src/lib/getopt.lua +++ b/src/lib/getopt.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2018-2023, OARC, Inc. +-- Copyright (c) 2018-2024 OARC, Inc. -- All rights reserved. -- -- This file is part of dnsjit. diff --git a/src/lib/ip.lua b/src/lib/ip.lua index 48b69e5..839af9b 100644 --- a/src/lib/ip.lua +++ b/src/lib/ip.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2018-2023, OARC, Inc. +-- Copyright (c) 2018-2024 OARC, Inc. -- All rights reserved. -- -- This file is part of dnsjit. diff --git a/src/lib/parseconf.lua b/src/lib/parseconf.lua index 374e9aa..45e04ca 100644 --- a/src/lib/parseconf.lua +++ b/src/lib/parseconf.lua @@ -1,4 +1,4 @@ --- Copyright (c) 2018-2023, OARC, Inc. +-- Copyright (c) 2018-2024 OARC, Inc. -- All rights reserved. -- -- This file is part of dnsjit. diff --git a/src/lib/trie.c b/src/lib/trie.c index 158c5ca..7a39a7d 100644 --- a/src/lib/trie.c +++ b/src/lib/trie.c @@ -39,17 +39,17 @@ enum knot_error { && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) /*! - * \brief Use a pointer alignment hack to save memory. - * - * When on, isbranch() relies on the fact that in leaf_t the first pointer - * is aligned on multiple of 4 bytes and that the flags bitfield is - * overlaid over the lowest two bits of that pointer. - * Neither is really guaranteed by the C standards; the second part should - * be OK with x86_64 ABI and most likely any other little-endian platform. - * It would be possible to manipulate the right bits portably, but it would - * complicate the code nontrivially. C++ doesn't even guarantee type-punning. - * In debug mode we check this works OK when creating a new trie instance. - */ + * \brief Use a pointer alignment hack to save memory. + * + * When on, isbranch() relies on the fact that in leaf_t the first pointer + * is aligned on multiple of 4 bytes and that the flags bitfield is + * overlaid over the lowest two bits of that pointer. + * Neither is really guaranteed by the C standards; the second part should + * be OK with x86_64 ABI and most likely any other little-endian platform. + * It would be possible to manipulate the right bits portably, but it would + * complicate the code nontrivially. C++ doesn't even guarantee type-punning. + * In debug mode we check this works OK when creating a new trie instance. + */ #define FLAGS_HACK 1 #else #define FLAGS_HACK 0 @@ -490,6 +490,10 @@ static int ns_longer_alloc(nstack_t* ns) memcpy(st, ns->stack, ns->len * sizeof(node_t*)); } else { st = realloc(ns->stack, new_size); + if (st == NULL) { + free(ns->stack); // left behind by realloc, callers bail out + ns->stack = NULL; + } } if (st == NULL) return KNOT_ENOMEM; @@ -732,8 +736,8 @@ int trie_get_leq(trie_t* tbl, const uint8_t* key, uint32_t len, trie_val_t** val // but try the previous child if key was less (it may not exist) bitmap_t b = twigbit(t, key, len); int i = hastwig(t, b) - ? twigoff(t, b) - (un_key < un_leaf) - : twigoff(t, b) - 1 /*twigoff returns successor when !hastwig*/; + ? twigoff(t, b) - (un_key < un_leaf) + : twigoff(t, b) - 1 /*twigoff returns successor when !hastwig*/; if (i >= 0) { ERR_RETURN(ns_longer(ns)); ns->stack[ns->len++] = twig(t, i); |