Fix and tidy up clear_rulist.

This commit is contained in:
Con Kolivas 2022-02-27 18:13:42 +11:00
parent ec54339be6
commit ec926c62b2
5 changed files with 19 additions and 18 deletions

15
lrzip.c
View file

@ -702,6 +702,21 @@ static void release_hashes(rzip_control *control)
dealloc(control->hash); 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 decompress one file from the command line
*/ */

View file

@ -470,7 +470,6 @@ struct rzip_control {
i64 (*match_len)(rzip_control *, struct rzip_state *, i64, i64, i64, i64 *); i64 (*match_len)(rzip_control *, struct rzip_state *, i64, i64, i64, i64 *);
pthread_t *pthreads; pthread_t *pthreads;
struct runzip_node *rulist;
struct runzip_node *ruhead; struct runzip_node *ruhead;
}; };

View file

@ -249,21 +249,6 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum,
return total; 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 /* decompress a section of an open file. Call fatal_return(() on error
return the number of bytes that have been retrieved return the number of bytes that have been retrieved
*/ */

View file

@ -22,7 +22,6 @@
#include "lrzip_private.h" #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); i64 runzip_fd(rzip_control *control, int fd_in, int fd_hist, i64 expected_size);
#endif #endif

View file

@ -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"); failure("Failed to calloc struct node in add_rulist\n");
node->sinfo = sinfo; node->sinfo = sinfo;
node->pthreads = control->pthreads; node->pthreads = control->pthreads;
node->prev = control->rulist;
lock_mutex(control, &control->control_lock);
node->prev = control->ruhead;
control->ruhead = node; control->ruhead = node;
unlock_mutex(control, &control->control_lock);
} }
/* close down an input stream */ /* close down an input stream */