Skip to content

Commit

Permalink
Use t_new in complicated t_malloc_no0 calls
Browse files Browse the repository at this point in the history
  • Loading branch information
mrannanj authored and GitLab committed May 30, 2016
1 parent 0175d37 commit 657d704
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/auth/auth-request-var-expand.c
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/lib-http/http-transfer-chunked.c
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/net.c
Expand Up @@ -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++) {
Expand Down

0 comments on commit 657d704

Please sign in to comment.