From: Martti Rannanjärvi Date: Tue, 17 May 2016 07:56:53 +0000 (+0300) Subject: Use t_new in complicated t_malloc_no0 calls X-Git-Tag: 2.3.0.rc1~3619 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=657d704a513d74c8bd0b2d355c88d8723a4ec69b;p=thirdparty%2Fdovecot%2Fcore.git Use t_new in complicated t_malloc_no0 calls --- diff --git a/src/auth/auth-request-var-expand.c b/src/auth/auth-request-var-expand.c index 3b0013601e..7bbceed854 100644 --- a/src/auth/auth-request-var-expand.c +++ b/src/auth/auth-request-var-expand.c @@ -78,8 +78,7 @@ auth_request_get_var_expand_table_full(const struct auth_request *auth_request, /* keep the extra fields at the beginning. the last static_tab field contains the ending NULL-fields. */ - tab = ret_tab = t_malloc_no0((*count + auth_count) * sizeof(*tab)); - memset(tab, 0, *count * sizeof(*tab)); + tab = ret_tab = t_new(struct var_expand_table, *count + auth_count); tab += *count; *count += auth_count; diff --git a/src/lib-http/http-transfer-chunked.c b/src/lib-http/http-transfer-chunked.c index fff71cf931..ac738749ea 100644 --- a/src/lib-http/http-transfer-chunked.c +++ b/src/lib-http/http-transfer-chunked.c @@ -623,7 +623,7 @@ http_transfer_chunked_ostream_sendv(struct ostream_private *stream, /* create new iovec */ prefix = t_strdup_printf("%llx\r\n", (unsigned long long)tcstream->chunk_size); iov_count = iov_count_new + 2; - iov_new = t_malloc_no0(sizeof(struct const_iovec) * iov_count); + iov_new = t_new(struct const_iovec, iov_count); iov_new[0].iov_base = prefix; iov_new[0].iov_len = strlen(prefix); memcpy(&iov_new[1], iov, sizeof(struct const_iovec) * iov_count_new); diff --git a/src/lib/net.c b/src/lib/net.c index 5cfc91b2d5..33186791e5 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -651,7 +651,7 @@ int net_gethostbyname(const char *addr, struct ip_addr **ips, count++; *ips_count = count; - *ips = t_malloc_no0(sizeof(struct ip_addr) * count); + *ips = t_new(struct ip_addr, count); count = 0; for (ai = origai; ai != NULL; ai = ai->ai_next, count++) {