Skip to content

Commit

Permalink
lib-http: Try to reuse memory for host->ips allocation.
Browse files Browse the repository at this point in the history
If the host already had an IP, most of the time ips_count doesn't change
anymore.
  • Loading branch information
sirainen authored and GitLab committed Jun 10, 2017
1 parent dead275 commit ae6a14c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib-http/http-client-host.c
Expand Up @@ -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;
Expand Down

0 comments on commit ae6a14c

Please sign in to comment.