summaryrefslogtreecommitdiffstats
path: root/bftw.c
diff options
context:
space:
mode:
Diffstat (limited to 'bftw.c')
-rw-r--r--bftw.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/bftw.c b/bftw.c
index bab357d..d216481 100644
--- a/bftw.c
+++ b/bftw.c
@@ -511,7 +511,6 @@ static int dirqueue_push(struct dirqueue *queue, struct dircache_entry *entry) {
/** Remove an entry from the dirqueue. */
static struct dircache_entry *dirqueue_pop(struct dirqueue *queue) {
if (queue->front == queue->back) {
- free(queue->entries);
return NULL;
}
@@ -522,6 +521,11 @@ static struct dircache_entry *dirqueue_pop(struct dirqueue *queue) {
return entry;
}
+/** Destroy a dirqueue. */
+static void dirqueue_free(struct dirqueue *queue) {
+ free(queue->entries);
+}
+
/** Fill in ftwbuf fields with information from a struct dirent. */
static void ftwbuf_use_dirent(struct BFTW *ftwbuf, const struct dirent *de) {
#if defined(_DIRENT_HAVE_D_TYPE) || defined(DT_DIR)
@@ -909,6 +913,7 @@ static void bftw_state_free(struct bftw_state *state) {
while (state->current) {
bftw_pop(state, false);
}
+ dirqueue_free(&state->queue);
dircache_free(&state->cache);