# HG changeset patch # User Timo Sirainen # Date 1509752557 -7200 # Node ID 7d5634889da8ec0df193878a0326098008347959 # Parent da955f909fddd0bac15594fcf8c79062902707e5 lib: net_ip2addr() - Optimize by allocating destination memory immediately It doesn't really matter if we allocate a few extra bytes. diff -r da955f909fdd -r 7d5634889da8 src/lib/net.c --- a/src/lib/net.c Sat Nov 04 01:40:24 2017 +0200 +++ b/src/lib/net.c Sat Nov 04 01:42:37 2017 +0200 @@ -931,13 +931,12 @@ const char *net_ip2addr(const struct ip_addr *ip) { #ifdef HAVE_IPV6 - char addr[MAX_IP_LEN+1]; + char *addr = t_malloc(MAX_IP_LEN+1); - addr[MAX_IP_LEN] = '\0'; if (inet_ntop(ip->family, &ip->u.ip6, addr, MAX_IP_LEN) == NULL) return ""; - return t_strdup(addr); + return addr; #else unsigned long ip4;