X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Ffolder.c;h=9d85e891f7952b28780e46616ed72d34cfe7798d;hp=e4779dc532e5c7e7dccb7fc352d9d90729b24970;hb=08aa8c17c3241bb5c6a997ed2e01e25a4d0089ce;hpb=4885712264980e6cbc2039f9158027bee9213475 diff --git a/uip/folder.c b/uip/folder.c index e4779dc..9d85e89 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -12,6 +12,7 @@ */ #include +#include #include static struct swit switches[] = { @@ -353,13 +354,11 @@ main (int argc, char **argv) /* Allocate initial space to record folder names */ maxfolders = NUMFOLDERS; - if ((folds = malloc (maxfolders * sizeof(char *))) == NULL) - adios (NULL, "unable to allocate storage for folder names"); + folds = mh_xmalloc (maxfolders * sizeof(char *)); /* Allocate initial space to record folder information */ maxFolderInfo = NUMFOLDERS; - if ((fi = malloc (maxFolderInfo * sizeof(*fi))) == NULL) - adios (NULL, "unable to allocate storage for folder info"); + fi = mh_xmalloc (maxFolderInfo * sizeof(*fi)); /* * Scan the folders @@ -394,22 +393,7 @@ main (int argc, char **argv) * Check if folder exists. If not, then see if * we should create it, or just exit. */ - if (stat (strncpy (buf, m_maildir (folder), sizeof(buf)), &st) == -1) { - if (errno != ENOENT) - adios (buf, "error on folder"); - if (fcreat == 0) { - /* ask before creating folder */ - cp = concat ("Create folder \"", buf, "\"? ", NULL); - if (!getanswer (cp)) - done (1); - free (cp); - } else if (fcreat == -1) { - /* do not create, so exit */ - done (1); - } - if (!makedir (buf)) - adios (NULL, "unable to create folder %s", buf); - } + create_folder (m_maildir (folder), fcreat, done); if (get_folder_info (folder, msg) && argfolder) { /* update current folder */ @@ -470,8 +454,7 @@ get_folder_info (char *fold, char *msg) */ if (total_folders >= maxFolderInfo) { maxFolderInfo += NUMFOLDERS; - if ((fi = realloc (fi, maxFolderInfo * sizeof(*fi))) == NULL) - adios (NULL, "unable to re-allocate storage for folder info"); + fi = mh_xrealloc (fi, maxFolderInfo * sizeof(*fi)); } fi[i].name = fold; @@ -775,8 +758,7 @@ addfold (char *fold) /* if necessary, reallocate the space for folder names */ if (foldp >= maxfolders) { maxfolders += NUMFOLDERS; - if ((folds = realloc (folds, maxfolders * sizeof(char *))) == NULL) - adios (NULL, "unable to re-allocate storage for folder names"); + folds = mh_xrealloc (folds, maxfolders * sizeof(char *)); } cp = getcpy (fold);