]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: Try to reuse memory for host->ips allocation.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 4 Feb 2017 18:45:30 +0000 (20:45 +0200)
committerGitLab <gitlab@git.dovecot.net>
Sat, 10 Jun 2017 08:34:57 +0000 (11:34 +0300)
If the host already had an IP, most of the time ips_count doesn't change
anymore.

src/lib-http/http-client-host.c

index 02ec9edbf4c599363929de9b9d4d399cfed039bb..3c04574f01f303a7bbd9d0073c8f99b193351027 100644 (file)
@@ -79,9 +79,9 @@ http_client_host_dns_callback(const struct dns_lookup_result *result,
                "DNS lookup successful; got %d IPs", result->ips_count);
 
        i_assert(result->ips_count > 0);
-       i_free(host->ips);
+       host->ips = i_realloc_type(host->ips, struct ip,
+                                  host->ips_count, result->ips_count);
        host->ips_count = result->ips_count;
-       host->ips = i_new(struct ip_addr, host->ips_count);
        memcpy(host->ips, result->ips, sizeof(*host->ips) * host->ips_count);
 
        host->ips_timeout = ioloop_timeval;