From c14f9ccab305a9b4065f430359069dc6200d3d4f Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Tue, 3 Mar 2015 14:15:09 +1100 Subject: [PATCH] Increase maxram when we abandon use of temporary input/output buffers --- lrzip.c | 12 ++++++++++-- lrzip_core.h | 5 +++-- main.c | 4 ++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lrzip.c b/lrzip.c index a58103f..22ca862 100644 --- a/lrzip.c +++ b/lrzip.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2013 Con Kolivas + Copyright (C) 2006-2015 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998-2003 Andrew Tridgell @@ -504,10 +504,15 @@ static bool open_tmpoutbuf(rzip_control *control) return true; } +/* We've decided to use a temporary output file instead of trying to store + * all the output buffer in ram so we can free up the ram and increase the + * maximum sizes of ram we can allocate */ void close_tmpoutbuf(rzip_control *control) { control->flags &= ~FLAG_TMP_OUTBUF; free(control->tmp_outbuf); + if (!BITS32) + control->usable_ram = control->maxram += control->ramsize / 18; } static bool open_tmpinbuf(rzip_control *control) @@ -534,10 +539,13 @@ bool clear_tmpinfile(rzip_control *control) return true; } +/* As per temporary output file but for input file */ void close_tmpinbuf(rzip_control *control) { control->flags &= ~FLAG_TMP_INBUF; free(control->tmp_inbuf); + if (!BITS32) + control->usable_ram = control->maxram += control->ramsize / 18; } static int get_pass(rzip_control *control, char *s) @@ -1215,7 +1223,7 @@ error: return false; } -bool initialize_control(rzip_control *control) +bool initialise_control(rzip_control *control) { struct timeval tv; char *eptr; /* for environment */ diff --git a/lrzip_core.h b/lrzip_core.h index 7d3cec8..10ec45a 100644 --- a/lrzip_core.h +++ b/lrzip_core.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2011 Con Kolivas + Copyright (C) 2006-2015 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998-2003 Andrew Tridgell @@ -41,7 +41,8 @@ void close_tmpoutbuf(rzip_control *control); void clear_tmpinbuf(rzip_control *control); bool clear_tmpinfile(rzip_control *control); void close_tmpinbuf(rzip_control *control); -bool initialize_control(rzip_control *control); +bool initialise_control(rzip_control *control); +#define initialize_control(_control) initialise_control(_control) extern void zpaq_compress(uchar *c_buf, i64 *c_len, uchar *s_buf, i64 s_len, int level, FILE *msgout, bool progress, long thread); extern void zpaq_decompress(uchar *s_buf, i64 *d_len, uchar *c_buf, i64 c_len, diff --git a/main.c b/main.c index 82c62f9..0a44990 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - Copyright (C) 2006-2013 Con Kolivas + Copyright (C) 2006-2015 Con Kolivas Copyright (C) 2011 Peter Hyman Copyright (C) 1998-2003 Andrew Tridgell @@ -199,7 +199,7 @@ int main(int argc, char *argv[]) control = &base_control; - initialize_control(control); + initialise_control(control); if (strstr(argv[0], "lrunzip")) control->flags |= FLAG_DECOMPRESS;