From 7f96490a8a9e75ce02d5339171d605eb3996ef71 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Thu, 4 Oct 2007 00:47:33 +0000 Subject: [PATCH] Fix memory leak. --- src/vip6-autod.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/vip6-autod.c b/src/vip6-autod.c index 1b60aa0..2d48dcd 100644 --- a/src/vip6-autod.c +++ b/src/vip6-autod.c @@ -29,8 +29,8 @@ #include /* not defined for gcc -ansi */ -typedef uint64_t __u64; -typedef int64_t __s64; +typedef unsigned long long __u64; +typedef signed long long __s64; #include #include @@ -153,6 +153,18 @@ static void cleanup_prefix(struct prefix_list *i) free(p); } +static inline void free_nid_list(struct nid_list *head) +{ + struct nid_list *p; + for (p = NULL; head; head = head->next) { + if (p) + free(p); + p = head; + } + if (p) + free(p); +} + static void do_slices_autoconf(struct prefix_list *head) { DIR *dp; @@ -161,6 +173,7 @@ static void do_slices_autoconf(struct prefix_list *head) struct vc_net_nx addr; struct prefix_list *i; struct nid_list *current = NULL, *n; + static struct nid_list *previous = NULL; if ((dp = opendir("/proc/virtnet")) == NULL) return; @@ -225,6 +238,9 @@ next: } } closedir(dp); + + free_nid_list(previous); + previous = current; } static int add_prefix(struct prefix_list *head, struct prefixmsg *msg, -- 2.43.0