~bitfehler/hdig

c436e452974dde28a6d5d6835f00f678179fa382 — Conrad Hoffmann 1 year, 3 months ago d84489b
Be diligent about freeing memory
1 files changed, 7 insertions(+), 1 deletions(-)

M main.ha
M main.ha => main.ha +7 -1
@@ 9,7 9,9 @@ use os;
use strings;

fn print_rr(rr: dns::rrecord) void = {
	fmt::printf("{}  {}", dns::unparse_domain(rr.name), rr.ttl)!;
	let domain = dns::unparse_domain(rr.name);
	defer free(domain);
	fmt::printf("{}  {}", domain, rr.ttl)!;
	match (rr.rdata) {
	case let d: dns::a =>
		fmt::printfln(" A {}", ip::string(d))!;


@@ 44,6 46,7 @@ export fn main() void = {
	let rtype = "A";
	let ipv4only = false;
	let ipv6only = false;
	defer free(servers);

	const cmd = getopt::parse(os::args,
		"simple DNS client",


@@ 96,8 99,10 @@ export fn main() void = {
				};
				append(server_ips, ips[j]);
			};
			free(ips);
		};
	};
	defer free(server_ips);

	let qtype = switch (rtype) {
	case "A" =>


@@ 149,6 154,7 @@ export fn main() void = {
		authority = [],
		additional = [],
	};
	defer free(query.questions[0].qname);

	let resp = match (dns::query(&query, server_ips...)) {
	case let err: dns::error =>