1From 09505532b49573663fb4ff4dad424dc2ef4c1f84 Mon Sep 17 00:00:00 2001
2From: Kyle Russell <bkylerussell@gmail.com>
3Date: Wed, 13 Jul 2016 17:30:00 -0400
4Subject: [PATCH] collector: Allocate space on heap for chunks
5
6Nicer for embedded devices which may have smaller stack limitations.
7
8Upstream-Status: Submitted [https://github.com/xrmx/bootchart/pull/74]
9
10Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
11---
12 collector/dump.c | 7 ++++---
13 1 file changed, 4 insertions(+), 3 deletions(-)
14
15diff --git a/collector/dump.c b/collector/dump.c
16index e673b5b..2f094b4 100644
17--- a/collector/dump.c
18+++ b/collector/dump.c
19@@ -184,12 +184,12 @@ static void dump_buffers (DumpState *s)
20 	log ("reading %d chunks (of %d) ...\n", max_chunk, s->map.max_chunk);
21 	for (i = 0; i < max_chunk; i++) {
22 		FILE *output;
23-		char buffer[CHUNK_SIZE];
24-		Chunk *c = (Chunk *)&buffer;
25+		char *buffer = malloc(CHUNK_SIZE);
26+		Chunk *c = (Chunk *)buffer;
27 		size_t addr = (size_t) s->map.chunks[i];
28
29 		lseek (s->mem, addr, SEEK_SET);
30-		read (s->mem, &buffer, CHUNK_SIZE);
31+		read (s->mem, buffer, CHUNK_SIZE);
32 		/*      log ("type: '%s' len %d\n",
33 			c->dest_stream, (int)c->length); */
34
35@@ -197,6 +197,7 @@ static void dump_buffers (DumpState *s)
36 		fwrite (c->data, 1, c->length, output);
37 		bytes_dumped += c->length;
38 		fclose (output);
39+                free(buffer);
40 	}
41 	log ("wrote %ld kb\n", (long)(bytes_dumped+1023)/1024);
42 }
43--
442.7.4
45
46