Skip to content

Commit

Permalink
Don't allocate a huge parse tree all at once.
Browse files Browse the repository at this point in the history
This was causing issues for embedded usage:
zauberzeug/lizard#23
..and was never really necessary anyway.
  • Loading branch information
ianh committed Dec 13, 2024
1 parent c2be1d5 commit a3470af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/6a-generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ void generate(struct generator *gen)
output_line(out, "static bool grow_tree(struct %%prefix_tree *tree, size_t size)");
output_line(out, "{");
output_line(out, " size_t n = tree->parse_tree_size;");
output_line(out, " while (n < size || n < 4096)");
output_line(out, " while (n < size)");
output_line(out, " n = (n + 1) * 3 / 2;");
output_line(out, " uint8_t *parse_tree = realloc(tree->parse_tree, n);");
output_line(out, " if (!parse_tree)");
Expand Down

0 comments on commit a3470af

Please sign in to comment.