diff --git a/src/core.c b/src/core.c index 4216af37..ed3b7bcf 100644 --- a/src/core.c +++ b/src/core.c @@ -640,6 +640,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ(nameserver, &update_dns_data) parse_nameserver_arg(obj, arg); obj->callbacks.print = &print_nameserver; + obj->callbacks.free = &free_dns_data; END OBJ(offset, 0) obj->data.l = arg ? atoi(arg) : 1; obj->callbacks.print = &new_offset; @@ -1848,9 +1849,6 @@ void free_text_objects(struct text_object *root, int internal) } break; #endif - case OBJ_nameserver: - free_dns_data(); - break; #ifdef __linux__ case OBJ_top: case OBJ_top_mem: diff --git a/src/net_stat.c b/src/net_stat.c index 97d062a4..33068e49 100644 --- a/src/net_stat.c +++ b/src/net_stat.c @@ -383,9 +383,12 @@ static struct { .ns_list = NULL, }; -void free_dns_data(void) +void free_dns_data(struct text_object *obj) { int i; + + (void)obj; + for (i = 0; i < dns_data.nscount; i++) free(dns_data.ns_list[i]); if (dns_data.ns_list) @@ -406,7 +409,7 @@ void update_dns_data(void) last_dns_update = current_update_time; */ - free_dns_data(); + free_dns_data(NULL); if ((fp = fopen("/etc/resolv.conf", "r")) == NULL) return; diff --git a/src/net_stat.h b/src/net_stat.h index db0018c1..28479b15 100644 --- a/src/net_stat.h +++ b/src/net_stat.h @@ -93,7 +93,7 @@ void parse_if_up_arg(struct text_object *, const char *); int interface_up(struct text_object *); void free_if_up(struct text_object *); -void free_dns_data(void); +void free_dns_data(struct text_object *); void update_dns_data(void); void parse_nameserver_arg(struct text_object *, const char *); void print_nameserver(struct text_object *, char *, int);