summaryrefslogtreecommitdiffstats
path: root/buffy.c
diff options
context:
space:
mode:
authorBrendan Cully <brendan@kublai.com>2009-08-09 14:45:31 -0700
committerBrendan Cully <brendan@kublai.com>2009-08-09 14:45:31 -0700
commit61d6c8cd224bea085d4133aee3129a6c0c45bbb8 (patch)
treeb47668124555e6f3f9c92e597dfdd342f81f73e5 /buffy.c
parent17ef99506f8d6297b9b077078d70fd6b76c8ffef (diff)
Add buffy_new and buffy_free abstractions.
Diffstat (limited to 'buffy.c')
-rw-r--r--buffy.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/buffy.c b/buffy.c
index f2d02f4a..614bf115 100644
--- a/buffy.c
+++ b/buffy.c
@@ -193,6 +193,23 @@ void mutt_update_mailbox (BUFFY * b)
return;
}
+static BUFFY *buffy_new (const char *path)
+{
+ BUFFY* buffy;
+
+ buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
+ strfcpy (buffy->path, path, sizeof (buffy->path));
+ buffy->next = NULL;
+ buffy->magic = 0;
+
+ return buffy;
+}
+
+static void buffy_free (BUFFY **mailbox)
+{
+ FREE (mailbox); /* __FREE_CHECKED__ */
+}
+
int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *err)
{
BUFFY **tmp,*tmp1;
@@ -211,7 +228,7 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
for (tmp = &Incoming; *tmp;)
{
tmp1=(*tmp)->next;
- FREE (tmp); /* __FREE_CHECKED__ */
+ buffy_free (tmp);
*tmp=tmp1;
}
return 0;
@@ -239,21 +256,14 @@ int mutt_parse_mailboxes (BUFFER *path, BUFFER *s, unsigned long data, BUFFER *e
if(*tmp)
{
tmp1=(*tmp)->next;
- FREE (tmp); /* __FREE_CHECKED__ */
+ buffy_free (tmp);
*tmp=tmp1;
}
continue;
}
if (!*tmp)
- {
- *tmp = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
- strfcpy ((*tmp)->path, buf, sizeof ((*tmp)->path));
- (*tmp)->next = NULL;
- /* it is tempting to set magic right here */
- (*tmp)->magic = 0;
-
- }
+ *tmp = buffy_new (buf);
(*tmp)->new = 0;
(*tmp)->notified = 1;