Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

more initialization stuff out of main(), remove weird coincidentally …

…successful one_g variable
  • Loading branch information...
commit 1c64dcfb312b94b2fa563a9cd24c3756d4d1bfe6 1 parent cfd6915
discomfitor authored committed
View
2  lrzip_private.h
@@ -177,6 +177,8 @@ typedef struct md5_ctx md5_ctx;
#define SALT_LEN 8
#define CBC_LEN 16
+#define one_g (1000 * 1024 * 1024)
+
#if defined(NOTHREAD) || !defined(_SC_NPROCESSORS_ONLN)
# define PROCESSORS (1)
#else
View
22 main.c
@@ -629,27 +629,7 @@ int main(int argc, char *argv[])
}
}
- /* 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);
-
+ setup_ram(control);
show_summary();
gettimeofday(&start_time, NULL);
View
2  stream.c
@@ -662,8 +662,6 @@ static int lzo_decompress_buf(rzip_control *control __UNUSED__, struct uncomp_th
/* WORK FUNCTIONS */
-i64 one_g = 1000 * 1024 * 1024;
-
/* Look at whether we're writing to a ram location or physical files and write
* the data accordingly. */
ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret)
View
1  stream.h
@@ -38,6 +38,5 @@ i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len
int close_stream_out(rzip_control *control, void *ss);
int close_stream_in(void *ss);
ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret);
-i64 one_g;
#endif
View
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;
View
1  util.h
@@ -27,6 +27,7 @@ void unlink_files(void);
void register_outputfile(FILE *f);
void fatal(const char *format, ...);
void failure(const char *format, ...);
+void setup_ram(rzip_control *control);
void round_to_page(i64 *size);
void get_rand(uchar *buf, int len);
void lrz_stretch(rzip_control *control);
Please sign in to comment.
Something went wrong with that request. Please try again.