Skip to content

DnsResolver

Description

In-tree resolver state. Created via DnsResolverInit (which reads /etc/hosts and /etc/resolv.conf from disk), torn down via DnsResolverDeinit. No globals, no shared cache; create one per subsystem that needs resolution.

Usage example (Cross-references)

Usage examples (Cross-references)
            u32        timeout_ms;
            u32        retries;
        } DnsResolver;
    
        ///
        /// TAGS: Dns, Resolve, Init
        ///
        bool dns_resolver_init(DnsResolver *out, Allocator *alloc);
    #define DnsResolverInit(...)          OVERLOAD(DnsResolverInit, __VA_ARGS__)
    #define DnsResolverInit_1(out)        dns_resolver_init((out), MisraScope)
        /// TAGS: Dns, Resolve, Init, Hosts
        ///
        bool dns_resolver_add_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddPath(...)          OVERLOAD(DnsResolverAddPath, __VA_ARGS__)
        ///
        bool dns_resolver_add_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddPath(...)          OVERLOAD(DnsResolverAddPath, __VA_ARGS__)
    #define DnsResolverAddPath_2(self, p)    dns_resolver_add_path_str((self), (p))
    #define DnsResolverAddPath_3(self, p, n) dns_resolver_add_path_zstr((self), (p), (n))
    
        bool dns_resolver_add_hosts_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_hosts_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddHostsPath(...)          OVERLOAD(DnsResolverAddHostsPath, __VA_ARGS__)
    
        bool dns_resolver_add_hosts_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_hosts_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddHostsPath(...)          OVERLOAD(DnsResolverAddHostsPath, __VA_ARGS__)
    #define DnsResolverAddHostsPath_2(self, p)    dns_resolver_add_hosts_path_str((self), (p))
    #define DnsResolverAddHostsPath_3(self, p, n) dns_resolver_add_hosts_path_zstr((self), (p), (n))
    
        bool dns_resolver_add_resolv_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_resolv_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddResolvPath(...)          OVERLOAD(DnsResolverAddResolvPath, __VA_ARGS__)
    
        bool dns_resolver_add_resolv_path_str(DnsResolver *self, const Str *path);
        bool dns_resolver_add_resolv_path_zstr(DnsResolver *self, Zstr path, u64 len);
    #define DnsResolverAddResolvPath(...)          OVERLOAD(DnsResolverAddResolvPath, __VA_ARGS__)
    #define DnsResolverAddResolvPath_2(self, p)    dns_resolver_add_resolv_path_str((self), (p))
    #define DnsResolverAddResolvPath_3(self, p, n) dns_resolver_add_resolv_path_zstr((self), (p), (n))
    
        bool dns_resolver_add_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_hosts_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_resolv_paths(DnsResolver *self, const Strs *paths);
    
        bool dns_resolver_add_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_hosts_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_resolv_paths(DnsResolver *self, const Strs *paths);
    #define DnsResolverAddPaths(self, paths)       dns_resolver_add_paths((self), (paths))
        bool dns_resolver_add_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_hosts_paths(DnsResolver *self, const Strs *paths);
        bool dns_resolver_add_resolv_paths(DnsResolver *self, const Strs *paths);
    #define DnsResolverAddPaths(self, paths)       dns_resolver_add_paths((self), (paths))
    #define DnsResolverAddHostsPaths(self, paths)  dns_resolver_add_hosts_paths((self), (paths))
        /// TAGS: Dns, Resolve, Init
        ///
        bool dns_resolver_add_nameserver(DnsResolver *self, SocketAddr ns);
    #define DnsResolverAddNameserver(self, ns) dns_resolver_add_nameserver((self), (ns))
        /// TAGS: Dns, Resolve, Deinit, Init
        ///
        void DnsResolverDeinit(DnsResolver *self);
    
        ///
        /// TAGS: Dns, Resolve, API
        ///
        bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_5(self, hostname, port, kind, out)                                                                  \
        ///
        bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_5(self, hostname, port, kind, out)                                                                  \
        _Generic(                                                                                                          \
        /// TAGS: Dns, Resolve, API
        ///
        bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_4_vec(self, spec, kind, out)                                                                        \
        ///
        bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out);
        bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out);
    #define DnsResolve_4_vec(self, spec, kind, out)                                                                        \
        _Generic(                                                                                                          \
        /// TAGS: Dns, Resolve, API
        ///
        bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out);
        bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out);
        ///
        bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out);
        bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out);
    
        ///
    // ---------------------------------------------------------------------------
    
    bool dns_resolver_init(DnsResolver *out, Allocator *alloc) {
        if (!out || !alloc) {
            return false;
    // ---------------------------------------------------------------------------
    
    static bool dns_add_path(DnsResolver *self, Zstr path, bool do_hosts, bool do_resolv) {
        if (!self || !path)
            return false;
    }
    
    static bool dns_add_path_len(DnsResolver *self, Zstr path, u64 len, bool do_hosts, bool do_resolv) {
        if (!self || !path)
            return false;
    }
    
    bool dns_resolver_add_path_str(DnsResolver *self, const Str *path) {
        if (!self || !path)
            return false;
    }
    
    bool dns_resolver_add_path_zstr(DnsResolver *self, Zstr path, u64 len) {
        return dns_add_path_len(self, path, len, true, true);
    }
    }
    
    bool dns_resolver_add_hosts_path_str(DnsResolver *self, const Str *path) {
        if (!self || !path)
            return false;
    }
    
    bool dns_resolver_add_hosts_path_zstr(DnsResolver *self, Zstr path, u64 len) {
        return dns_add_path_len(self, path, len, true, false);
    }
    }
    
    bool dns_resolver_add_resolv_path_str(DnsResolver *self, const Str *path) {
        if (!self || !path)
            return false;
    }
    
    bool dns_resolver_add_resolv_path_zstr(DnsResolver *self, Zstr path, u64 len) {
        return dns_add_path_len(self, path, len, false, true);
    }
    }
    
    bool dns_resolver_add_paths(DnsResolver *self, const Strs *paths) {
        if (!self || !paths)
            return false;
    }
    
    bool dns_resolver_add_hosts_paths(DnsResolver *self, const Strs *paths) {
        if (!self || !paths)
            return false;
    }
    
    bool dns_resolver_add_resolv_paths(DnsResolver *self, const Strs *paths) {
        if (!self || !paths)
            return false;
    }
    
    bool dns_resolver_add_nameserver(DnsResolver *self, SocketAddr ns) {
        if (!self)
            return false;
    }
    
    void DnsResolverDeinit(DnsResolver *self) {
        if (!self) {
            return;
    // response's id is checked to match before the records are extracted.
    static bool
        try_one_query(DnsResolver *self, const SocketAddr *ns, Zstr hostname, DnsType qtype, u16 port, DnsAddrs *out) {
        // Per-call scratch: one DNS query buffer (<= 1232 B) plus the parsed
        // response with its records vector. Everything is dropped at function
    }
    
    bool dns_resolve_5_zstr(DnsResolver *self, Zstr hostname, u16 port, SocketKind kind, DnsAddrs *out) {
        (void)kind; // protocol byte doesn't affect resolution
        if (!self || !hostname || !out) {
    }
    
    bool dns_resolve_4_vec_zstr(DnsResolver *self, Zstr spec, SocketKind kind, DnsAddrs *out) {
        if (!self || !spec || !out) {
            return false;
    }
    
    bool dns_resolve_5_str(DnsResolver *self, const Str *hostname, u16 port, SocketKind kind, DnsAddrs *out) {
        if (!self || !hostname || !out) {
            return false;
    }
    
    bool dns_resolve_4_vec_str(DnsResolver *self, const Str *spec, SocketKind kind, DnsAddrs *out) {
        if (!self || !spec || !out) {
            return false;
    }
    
    bool dns_resolve_4_one_zstr(DnsResolver *self, Zstr spec, SocketKind kind, SocketAddr *out) {
        if (!self || !spec || !out) {
            return false;
    }
    
    bool dns_resolve_4_one_str(DnsResolver *self, const Str *spec, SocketKind kind, SocketAddr *out) {
        if (!self || !spec || !out) {
            return false;
            }
    
            DnsResolver r;
            if (!DnsResolverInit(&r, alloc)) {
                LOG_ERROR("failed to init resolver");
            }
    
            DnsResolver resolver;
            if (!DnsResolverInit(&resolver, alloc)) {
                LOG_ERROR("failed to init DNS resolver");
    // This is what `DnsResolverInit` produces minus the /etc parsing, so the
    // crafted-table and Add*Path tests start from a known-empty state.
    static void resolver_init_empty(DnsResolver *r, Allocator *a) {
        r->allocator   = a;
        r->hosts       = VecInitT(r->hosts, a);
    }
    
    static void hosts_push_v4(DnsResolver *r, Zstr name, u8 b0, u8 b1, u8 b2, u8 b3) {
        HostsEntry e = {0};
        e.name       = StrInitFromCstr(name, ZstrLen(name), r->allocator);
    }
    
    static void hosts_push_v6(DnsResolver *r, Zstr name, const u8 ip16[16]) {
        HostsEntry e = {0};
        e.name       = StrInitFromCstr(name, ZstrLen(name), r->allocator);
    
    // Canonical crafted table used by the resolve-API tests.
    static void resolver_init_crafted(DnsResolver *r, Allocator *a) {
        resolver_init_empty(r, a);
        hosts_push_v4(r, "single", 1, 2, 3, 4);
    
    // Compare nameserver `i` formatted as "ip:port" against `expect`.
    static bool ns_fmt_is(DnsResolver *r, u64 i, Allocator *a, Zstr expect) {
        if (VecLen(&r->nameservers) <= i) {
            return false;
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        bool        ok = DnsResolverInit(&r, a);
        if (!ok) {
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        DnsResolverInit(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "127.0.0.1 localhost\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "192.168.1.5 host.example alias1 alias2 alias3\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.0.0.2 namex # trailing comment words\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.0.0.2 namex#tail\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "  \t 172.16.0.9\thostt\talt\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.1.1.1 MixedCaseHost\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.1.1.2 @AZ[`M\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.0.0.1 a\n8.8.8.8 dns");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "10.0.0.1 a\n# trailing comment no newline");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "::1 ip6-localhost\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        DnsResolverAddHostsPath(&r, "sysdns_definitely_missing_zzqq", 30);
        StrPushBackMany(&body, "10.20.30.40 farhost\n", ZstrLen("10.20.30.40 farhost\n"));
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, StrBegin(&body));
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver ::1\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "# nameserver 9.9.9.9\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "; nameserver 9.9.9.9\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "search 8.8.8.8\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserverx 8.8.8.8\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver\t8.8.4.4\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "  nameserver 8.8.8.8\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver not.an.ip.999\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver 8.8.8.8#note\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver \n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "nameserver 8.8.8.8");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "a@z", 10, 0, 0, 1);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "host", 10, 0, 0, 2);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "a.b.c", 10, 0, 0, 3);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "host", 10, 0, 0, 4);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "myhost", 1, 2, 3, 4);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        u8 ip6[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; // ::1
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(a, "1.2.3.4 lenhost\n");
        size baseline = DebugAllocatorLiveCount(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        DnsResolverAddHostsPath(&r, StrBegin(&path), plen);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str path = write_temp(
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Str  path  = write_temp(a, "nameserver 4.3.2.1\n");
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_empty(&r, a);
        hosts_push_v4(&r, "", 7, 7, 7, 7);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        bool        ok = dns_resolver_init(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        bool        ok = dns_resolver_init(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        bool        ok = dns_resolver_init(&r, a);
        Allocator       *a     = ALLOCATOR_OF(&alloc);
    
        DnsResolver r;
        bool        ok = dns_resolver_init(&r, a);
    
    static bool test_init_null_alloc(void) {
        DnsResolver r;
        bool        got = dns_resolver_init(&r, NULL);
        return !got;
        size           baseline = DebugAllocatorLiveCount(&alloc);
    
        DnsResolver r;
        resolver_init_crafted(&r, a);
        size           baseline = DebugAllocatorLiveCount(&alloc);
    
        DnsResolver r;
        bool        ok = dns_resolver_init(&r, a);
Last updated on