From: Francois Fleuret Date: Sat, 14 Mar 2009 17:10:21 +0000 (+0100) Subject: Allocate the line array *after* the argument parsing so that we X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=42294c6ab7b85294b8f2931291c1dcc977642806;p=selector.git 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. --- 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); }