From 04d1d6ae25852942386ba159556cee7fd8115317 Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Mon, 28 Nov 2016 14:11:46 -0700 Subject: Convert file storage from stack to heap Was storing file in the stack, which was causing segfaults on data sets larger than 8 MB. Converted to use heap for file storage to expand support for larger files. --- src/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index fcf8c1e..23cd9d7 100644 --- a/src/main.c +++ b/src/main.c @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) { printf("Allocating memory\n"); // Allocate array for file contents - char data[flen + 1]; + char* data = malloc(flen + 1); unsigned int i = 0; char c; printf("Reading data to memory\n"); @@ -150,6 +150,9 @@ int main(int argc, char *argv[]) { fclose(f); printf("Searching for palindromes\n"); + + find_largest_palindromes(data); + free(data); return 0; } -- cgit v1.2.3