From 3c66cad68455701d44f507d8d26ffb41bee5cc03 Mon Sep 17 00:00:00 2001 From: Titouan Rigoudy Date: Fri, 24 Oct 2014 22:21:23 -0400 Subject: [PATCH] Increased buffer size to 10MB, allocated on the heap --- arithmetic_progressions/arithmetic_progressions.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arithmetic_progressions/arithmetic_progressions.c b/arithmetic_progressions/arithmetic_progressions.c index c0ea967..4a8d2dc 100644 --- a/arithmetic_progressions/arithmetic_progressions.c +++ b/arithmetic_progressions/arithmetic_progressions.c @@ -7,7 +7,7 @@ #define INTS_START_SIZE 8 #define INTS_DELIM " \t\n" -#define BUF_SIZE 1 << 20 +#define BUF_SIZE 10000000 #define LINE_SIZE 16 #define BIG_MOD 1000003 @@ -229,7 +229,10 @@ int handle_query(char *str, int n, struct adp *adp, long *ptree, long *vtree) { } int main(int argc, char **argv) { - char buf[BUF_SIZE]; + char *buf = malloc(BUF_SIZE * sizeof *buf); + if (buf == NULL) { + return 0; + } fread(buf, BUF_SIZE, 1, stdin); char *line = strtok(buf, "\n");