X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=sbr%2Fcrawl_folders.c;h=71646162b0f2934bc856ab2ddc78a5f16440d30c;hp=b59a8e7ea718440fc5f2ca21621d8f491c936544;hb=fc9279e818dfc96c63a5d75a89080cc68cfe1170;hpb=2abb9a7cfb0930e27062088734d306e7d78e4cc2 diff --git a/sbr/crawl_folders.c b/sbr/crawl_folders.c index b59a8e7..7164616 100644 --- a/sbr/crawl_folders.c +++ b/sbr/crawl_folders.c @@ -31,7 +31,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) { @@ -68,7 +68,7 @@ add_children(char *name, struct crawl_context *crawl) } if (strcmp(name, ".") == 0) { - prefix = getcpy(""); + prefix = mh_xstrdup(""); } else { prefix = concat(name, "/", (void *)NULL); } @@ -102,12 +102,12 @@ add_children(char *name, struct crawl_context *crawl) /* add_folder saves child in the list, don't free it */ add_folder(child, crawl); } else { - free(child); + mh_free0(&child); } } closedir(dd); - free(prefix); + mh_free0(&prefix); } static void @@ -142,10 +142,10 @@ crawl_folders_body(struct crawl_context *crawl, char *dir, void crawl_folders(char *dir, crawl_callback_t *callback, void *baton) { - struct crawl_context *crawl = mh_xmalloc(sizeof(*crawl)); + struct crawl_context *crawl = mh_xcalloc(1, sizeof(*crawl)); crawl->max = CRAWL_NUMFOLDERS; crawl->total = crawl->start = crawl->foldp = 0; - crawl->folders = mh_xmalloc(crawl->max * sizeof(*crawl->folders)); + crawl->folders = mh_xcalloc(crawl->max, sizeof(*crawl->folders)); crawl_folders_body(crawl, dir, callback, baton); @@ -153,6 +153,6 @@ crawl_folders(char *dir, crawl_callback_t *callback, void *baton) ** Note that we "leak" the folder names, on the assumption that the ** caller is using them. */ - free(crawl->folders); - free(crawl); + mh_free0(&(crawl->folders)); + mh_free0(&crawl); }