Small cleanups in frec_src datastucture handling.
diff --git a/src/forward.c b/src/forward.c
index 70b84d7..f94c4cf 100644
--- a/src/forward.c
+++ b/src/forward.c
@@ -361,7 +361,10 @@
if (!daemon->free_frec_src &&
daemon->frec_src_count < daemon->ftabsize &&
(daemon->free_frec_src = whine_malloc(sizeof(struct frec_src))))
- daemon->frec_src_count++;
+ {
+ daemon->frec_src_count++;
+ daemon->free_frec_src->next = NULL;
+ }
/* If we've been spammed with many duplicates, just drop the query. */
if (daemon->free_frec_src)
@@ -398,6 +401,7 @@
forward->frec_src.orig_id = ntohs(header->id);
forward->frec_src.dest = *dst_addr;
forward->frec_src.iface = dst_iface;
+ forward->frec_src.next = NULL;
forward->new_id = get_id();
forward->fd = udpfd;
memcpy(forward->hash, hash, HASH_SIZE);
@@ -2275,16 +2279,16 @@
static void free_frec(struct frec *f)
{
- struct frec_src *src, *tmp;
-
- /* add back to freelist of not the record builtin to every frec. */
- for (src = f->frec_src.next; src; src = tmp)
- {
- tmp = src->next;
- src->next = daemon->free_frec_src;
- daemon->free_frec_src = src;
- }
+ struct frec_src *last;
+ /* add back to freelist if not the record builtin to every frec. */
+ for (last = f->frec_src.next; last && last->next; last = last->next) ;
+ if (last)
+ {
+ last->next = daemon->free_frec_src;
+ daemon->free_frec_src = f->frec_src.next;
+ }
+
f->frec_src.next = NULL;
free_rfd(f->rfd4);
f->rfd4 = NULL;