X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/788c353a8bee07520ae1a1de6fb7bdcdf1f4f1c7..6015bb1f7:/sbr/crawl_folders.c?ds=sidebyside diff --git a/sbr/crawl_folders.c b/sbr/crawl_folders.c index 4889bf1c..e7ab5e37 100644 --- a/sbr/crawl_folders.c +++ b/sbr/crawl_folders.c @@ -1,8 +1,4 @@ - -/* - * crawl_folders.c -- crawl folder hierarchy - * - * $Id$ +/* crawl_folders.c -- crawl folder hierarchy * * This code is Copyright (c) 2008, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for @@ -17,7 +13,6 @@ struct crawl_context { int max; /* how many folders we currently can hold in * the array `folders', increased by * CRAWL_NUMFOLDERS at a time */ - int total; /* how many `folders' actually has */ char **folders; /* the array of folders */ int start; int foldp; @@ -31,7 +26,7 @@ struct crawl_context { static void add_folder (char *fold, struct crawl_context *crawl) { - register int i, j; + int i, j; /* if necessary, reallocate the space for folder names */ if (crawl->foldp >= crawl->max) { @@ -49,7 +44,6 @@ add_folder (char *fold, struct crawl_context *crawl) return; } - crawl->total++; crawl->folders[crawl->foldp++] = fold; } @@ -68,7 +62,7 @@ add_children (char *name, struct crawl_context *crawl) } if (strcmp (name, ".") == 0) { - prefix = getcpy (""); + prefix = mh_xstrdup(""); } else { prefix = concat (name, "/", (void *)NULL); } @@ -137,9 +131,10 @@ crawl_folders_body (struct crawl_context *crawl, void crawl_folders (char *dir, crawl_callback_t *callback, void *baton) { - struct crawl_context *crawl = mh_xmalloc (sizeof(*crawl)); + struct crawl_context *crawl; + NEW(crawl); crawl->max = CRAWL_NUMFOLDERS; - crawl->total = crawl->start = crawl->foldp = 0; + crawl->start = crawl->foldp = 0; crawl->folders = mh_xmalloc (crawl->max * sizeof(*crawl->folders)); crawl_folders_body (crawl, dir, callback, baton);