Skip to content

Commit

Permalink
xzminidec: Create macro to set the maximum supported dictionary size.
Browse files Browse the repository at this point in the history
The macro can be overridden at compile time by setting something like:

    -DDICT_SIZE_MAX="(1U << 25)"
  • Loading branch information
JiaT75 committed Mar 22, 2024
1 parent 143e4d1 commit 48355f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion userspace/xzminidec.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include <string.h>
#include "xz.h"

#ifndef DICT_SIZE_MAX
# define DICT_SIZE_MAX (64U << 20)
#endif

static uint8_t in[BUFSIZ];
static uint8_t out[BUFSIZ];

Expand All @@ -44,7 +48,7 @@ int main(int argc, char **argv)
* Support up to 64 MiB dictionary. The actually needed memory
* is allocated once the headers have been parsed.
*/
s = xz_dec_init(XZ_DYNALLOC, 1 << 26);
s = xz_dec_init(XZ_DYNALLOC, DICT_SIZE_MAX);
if (s == NULL) {
msg = "Memory allocation failed\n";
goto error;
Expand Down

0 comments on commit 48355f1

Please sign in to comment.