Skip to content

Commit

Permalink
Replace xzfree() with free()
Browse files Browse the repository at this point in the history
when the former has no added value.  That is, when a new value
is assigned to the parameter on the next line.

In strarray_fini() the data is never read again, so there is need
to zero it.
  • Loading branch information
dilyanpalauzov committed Sep 24, 2023
1 parent 9743559 commit 9908944
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions imap/mailbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ static int parseentry_cb(int type, struct dlistsax_data *d)
break;
case DLISTSAX_KVLISTEND:
if (rock->doingacl) {
xzfree(rock->h->acl);
free(rock->h->acl);
rock->h->acl = buf_release(&rock->aclbuf);
rock->doingacl = 0;
}
Expand Down Expand Up @@ -1404,23 +1404,23 @@ static int parseentry_cb(int type, struct dlistsax_data *d)
buf_putc(&rock->aclbuf, '\t');
}
else if (rock->doingflags) {
xzfree(rock->h->flagname[rock->nflags]);
free(rock->h->flagname[rock->nflags]);
rock->h->flagname[rock->nflags++] = xstrdupnull(d->data);
}
else {
if (!strcmp(key, "I")) {
xzfree(rock->h->uniqueid);
free(rock->h->uniqueid);
rock->h->uniqueid = xstrdupnull(d->data);
}
else if (!strcmp(key, "N")) {
xzfree(rock->h->name);
free(rock->h->name);
rock->h->name = xstrdupnull(d->data);
}
else if (!strcmp(key, "T")) {
rock->h->mbtype = mboxlist_string_to_mbtype(d->data);
}
else if (!strcmp(key, "Q")) {
xzfree(rock->h->quotaroot);
free(rock->h->quotaroot);
rock->h->quotaroot = xstrdupnull(d->data);
}
}
Expand Down Expand Up @@ -6583,7 +6583,7 @@ HIDDEN int mailbox_rename_nocopy(struct mailbox *oldmailbox,
if (!silent) mailbox_modseq_dirty(oldmailbox);

/* update the name in the header */
xzfree(oldmailbox->h.name);
free(oldmailbox->h.name);
oldmailbox->h.name = xstrdup(newname);
oldmailbox->header_dirty = 1;

Expand Down
4 changes: 2 additions & 2 deletions imap/mboxlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,7 +1794,7 @@ EXPORTED int mboxlist_promote_intermediary(const char *mboxname)
&mbentry->partition);
if (r) goto done;
mbentry->mbtype &= ~MBTYPE_INTERMEDIATE;
xzfree(mbentry->acl);
free(mbentry->acl);
mbentry->acl = xstrdupnull(parent->acl);

r = mailbox_create(mboxname, mbentry->mbtype,
Expand All @@ -1809,7 +1809,7 @@ EXPORTED int mboxlist_promote_intermediary(const char *mboxname)
if (r) goto done;

// make sure all the fields are up-to-date
xzfree(mbentry->uniqueid);
free(mbentry->uniqueid);
mbentry->uniqueid = xstrdupnull(mailbox_uniqueid(mailbox));
mbentry->uidvalidity = mailbox->i.uidvalidity;
mbentry->createdmodseq = mailbox->i.createdmodseq;
Expand Down
6 changes: 3 additions & 3 deletions imap/reconstruct.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ static int do_reconstruct(struct findall_data *data, void *rock)
if (strcmpsafe(mailbox_uniqueid(mailbox), mbentry_byname->uniqueid)) {
printf("Wrong uniqueid in mbentry, fixing %s (%s -> %s)\n",
name, mbentry_byname->uniqueid, mailbox_uniqueid(mailbox));
xzfree(mbentry_byname->uniqueid);
free(mbentry_byname->uniqueid);
mbentry_byname->uniqueid = xstrdupnull(mailbox_uniqueid(mailbox));
mbentry_dirty = 1;
}
Expand All @@ -574,7 +574,7 @@ static int do_reconstruct(struct findall_data *data, void *rock)
printf("Wrong uniqueid! %s (should be %s)\n", mbentry_byid->name, name);
if (updateuniqueids) {
mailbox_make_uniqueid(mailbox);
xzfree(mbentry_byname->uniqueid);
free(mbentry_byname->uniqueid);
mbentry_byname->uniqueid = xstrdupnull(mailbox_uniqueid(mailbox));
mbentry_dirty = 1;
syslog (LOG_ERR, "uniqueid clash with %s - changed %s (%s => %s)",
Expand Down Expand Up @@ -641,7 +641,7 @@ static int do_reconstruct(struct findall_data *data, void *rock)
else {
printf("Wrong acl in mbentry %s (%s %s)\n",
name, mbentry_byname->acl, mailbox_acl(mailbox));
xzfree(mbentry_byname->acl);
free(mbentry_byname->acl);
mbentry_byname->acl = xstrdupnull(mailbox_acl(mailbox));
mbentry_dirty = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion imap/sync_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ static int cb_allmbox(const mbentry_t *mbentry, void *rock)
if (!strcmpsafe(userid, prev_userid))
goto done;

xzfree(prev_userid);
free(prev_userid);
prev_userid = xstrdup(userid);

r = sync_do_user(&sync_cs, userid, NULL);
Expand Down
2 changes: 1 addition & 1 deletion lib/strarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ EXPORTED void strarray_fini(strarray_t *sa)
if (!sa)
return;
for (i = 0 ; i < sa->count ; i++) {
xzfree(sa->data[i]);
free(sa->data[i]);
}
xzfree(sa->data);
sa->count = 0;
Expand Down

0 comments on commit 9908944

Please sign in to comment.