From 42294c6ab7b85294b8f2931291c1dcc977642806 Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Sat, 14 Mar 2009 18:10:21 +0100 Subject: [PATCH] Allocate the line array *after* the argument parsing so that we actually take into account the -l option, and do it dynamically to handle very large numbers of lines. --- selector.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/selector.cc b/selector.cc index 0062a3b..617edf0 100644 --- a/selector.cc +++ b/selector.cc @@ -48,7 +48,7 @@ const int buffer_size = 1024; // Yeah, global variables! -int nb_lines_max = 10000; +int nb_lines_max = 1000; char pattern_separator = ';'; int output_to_vt_buffer = 0; int with_colors = 1; @@ -322,7 +322,6 @@ void update_screen(int *current_line, int *temporary_line, int motion, int main(int argc, char **argv) { char buffer[buffer_size]; - char *lines[nb_lines_max]; int color_fg_modeline, color_bg_modeline; int color_fg_highlight, color_bg_highlight; @@ -424,6 +423,8 @@ int main(int argc, char **argv) { } } + char **lines = new char *[nb_lines_max]; + if(!input_filename[0]) { cerr << "You must specify a input file with -f." << endl; exit(1); @@ -581,6 +582,7 @@ int main(int argc, char **argv) { for(int l = 0; l < nb_lines; l++) { delete[] lines[l]; } + delete[] lines; exit(0); } -- 2.39.5