diff --git a/lrzip.c b/lrzip.c index 69fec18..579219a 100644 --- a/lrzip.c +++ b/lrzip.c @@ -702,6 +702,21 @@ static void release_hashes(rzip_control *control) dealloc(control->hash); } +static void clear_rulist(rzip_control *control) +{ + while (control->ruhead) { + struct runzip_node *node = control->ruhead; + struct stream_info *sinfo = node->sinfo; + + dealloc(sinfo->ucthreads); + dealloc(node->pthreads); + dealloc(sinfo->s); + dealloc(sinfo); + control->ruhead = node->prev; + dealloc(node); + } +} + /* decompress one file from the command line */ diff --git a/lrzip_private.h b/lrzip_private.h index 8296e86..0e853f7 100644 --- a/lrzip_private.h +++ b/lrzip_private.h @@ -470,7 +470,6 @@ struct rzip_control { i64 (*match_len)(rzip_control *, struct rzip_state *, i64, i64, i64, i64 *); pthread_t *pthreads; - struct runzip_node *rulist; struct runzip_node *ruhead; }; diff --git a/runzip.c b/runzip.c index 36ecee9..e3a04b2 100644 --- a/runzip.c +++ b/runzip.c @@ -249,21 +249,6 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum, return total; } -void clear_rulist(rzip_control *control) -{ - while (control->ruhead) { - struct runzip_node *node = control->ruhead; - struct stream_info *sinfo = node->sinfo; - - dealloc(sinfo->ucthreads); - dealloc(node->pthreads); - dealloc(sinfo->s); - dealloc(sinfo); - control->ruhead = node->prev; - dealloc(node); - } -} - /* decompress a section of an open file. Call fatal_return(() on error return the number of bytes that have been retrieved */ diff --git a/runzip.h b/runzip.h index a275bd3..9f7826b 100644 --- a/runzip.h +++ b/runzip.h @@ -22,7 +22,6 @@ #include "lrzip_private.h" -void clear_rulist(rzip_control *control); i64 runzip_fd(rzip_control *control, int fd_in, int fd_hist, i64 expected_size); #endif diff --git a/stream.c b/stream.c index 1215b9e..eaaa425 100644 --- a/stream.c +++ b/stream.c @@ -1853,8 +1853,11 @@ static void add_to_rulist(rzip_control *control, struct stream_info *sinfo) failure("Failed to calloc struct node in add_rulist\n"); node->sinfo = sinfo; node->pthreads = control->pthreads; - node->prev = control->rulist; + + lock_mutex(control, &control->control_lock); + node->prev = control->ruhead; control->ruhead = node; + unlock_mutex(control, &control->control_lock); } /* close down an input stream */