mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Provide a helper function to round a value up to the nearest page size for malloc optimisations.
This commit is contained in:
parent
d5c00f96f7
commit
6bb837761f
13
util.c
13
util.c
|
|
@ -149,6 +149,15 @@ void round_to_page(i64 *size)
|
|||
*size = PAGE_SIZE;
|
||||
}
|
||||
|
||||
size_t round_up_page(rzip_control *control, size_t len)
|
||||
{
|
||||
int rem = len % control->page_size;
|
||||
|
||||
if (rem)
|
||||
len += control->page_size - rem;
|
||||
return len;
|
||||
}
|
||||
|
||||
bool get_rand(rzip_control *control, uchar *buf, int len)
|
||||
{
|
||||
int fd, i;
|
||||
|
|
@ -164,7 +173,9 @@ bool get_rand(rzip_control *control, uchar *buf, int len)
|
|||
fatal_return(("Failed to close fd in get_rand\n"), false);
|
||||
}
|
||||
return true;
|
||||
}bool read_config(rzip_control *control)
|
||||
}
|
||||
|
||||
bool read_config(rzip_control *control)
|
||||
{
|
||||
/* check for lrzip.conf in ., $HOME/.lrzip and /etc/lrzip */
|
||||
char *HOME, homeconf[255];
|
||||
|
|
|
|||
1
util.h
1
util.h
|
|
@ -82,6 +82,7 @@ static inline void failure(const rzip_control *control, unsigned int line, const
|
|||
void setup_overhead(rzip_control *control);
|
||||
void setup_ram(rzip_control *control);
|
||||
void round_to_page(i64 *size);
|
||||
size_t round_up_page(rzip_control *control, size_t len);
|
||||
bool get_rand(rzip_control *control, uchar *buf, int len);
|
||||
bool read_config(rzip_control *control);
|
||||
void lrz_stretch(rzip_control *control);
|
||||
|
|
|
|||
Loading…
Reference in a new issue