mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-04-04 22:07:42 +00:00
more initialization stuff out of main(), remove weird coincidentally successful one_g variable
This commit is contained in:
parent
cfd6915b20
commit
1c64dcfb31
6 changed files with 27 additions and 24 deletions
23
util.c
23
util.c
|
|
@ -133,6 +133,29 @@ void failure(const char *format, ...)
|
|||
fatal_exit();
|
||||
}
|
||||
|
||||
void setup_ram(rzip_control *control)
|
||||
{
|
||||
/* Use less ram when using STDOUT to store the temporary output file. */
|
||||
if (STDOUT && ((STDIN && DECOMPRESS) || !(DECOMPRESS || TEST_ONLY)))
|
||||
control->maxram = control->ramsize * 2 / 9;
|
||||
else
|
||||
control->maxram = control->ramsize / 3;
|
||||
if (BITS32) {
|
||||
/* Decrease usable ram size on 32 bits due to kernel /
|
||||
* userspace split. Cannot allocate larger than a 1
|
||||
* gigabyte chunk due to 32 bit signed long being
|
||||
* used in alloc, and at most 3GB can be malloced, and
|
||||
* 2/3 of that makes for a total of 2GB to be split
|
||||
* into thirds.
|
||||
*/
|
||||
control->usable_ram = MAX(control->ramsize - 900000000ll, 900000000ll);
|
||||
control->maxram = MIN(control->maxram, control->usable_ram);
|
||||
control->maxram = MIN(control->maxram, one_g * 2 / 3);
|
||||
} else
|
||||
control->usable_ram = control->maxram;
|
||||
round_to_page(&control->maxram);
|
||||
}
|
||||
|
||||
void round_to_page(i64 *size)
|
||||
{
|
||||
*size -= *size % PAGE_SIZE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue