From cd53949c928dc3d848658661c58b7705b3904681 Mon Sep 17 00:00:00 2001 From: Christiano Haesbaert Date: Sun, 9 Feb 2025 00:26:25 +0100 Subject: [PATCH] Cleanup allocated dns runtime data While harmless, the runtime should clean up non-user allocated data. On the same veign of: https://github.com/odin-lang/Odin/pull/4680 I'm kinda new to Odin and wrote netcat, in order to get a clean valgrind run, one has to manually destroy dns_configuration: https://github.com/haesbaert/learn-odin/blob/main/netcat/netcat.odin#L168-L169 While here unexport the destroy procedure and make destruction idempotent. --- core/net/dns.odin | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/net/dns.odin b/core/net/dns.odin index 6d5dfea23b3..17fc2dbb24c 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -50,9 +50,12 @@ init_dns_configuration :: proc() { dns_configuration.hosts_file, _ = replace_environment_path(dns_configuration.hosts_file) } +@(fini, private) destroy_dns_configuration :: proc() { delete(dns_configuration.resolv_conf) + dns_configuration.resolv_conf = "" delete(dns_configuration.hosts_file) + dns_configuration.hosts_file = "" } dns_configuration := DEFAULT_DNS_CONFIGURATION