From fb592b6f13278ed96a6787974d6b486d1c336ace Mon Sep 17 00:00:00 2001 From: Lennart Buhl Date: Sat, 2 Nov 2013 20:50:42 +0100 Subject: [PATCH] fix indizes --- src/display.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/display.c b/src/display.c index 9d8496e..69746e9 100644 --- a/src/display.c +++ b/src/display.c @@ -23,7 +23,7 @@ void cleanup_display() { uint32_t height; // normally 25, may vary char *image; // dimension is width x height */ -void print_current_image(struct message* msg, int start, int end) { +static void print_current_image(const struct message* msg, int start, int end) { end = 80; // end is ignored and 80 is used, should be handled properly later //move(0,0); // start in the upper left corner @@ -31,12 +31,11 @@ void print_current_image(struct message* msg, int start, int end) { for (int row=0; row < 25; row++) { // iterate over rows char *original_line = pic + row * msg->width; // pointer to the start of the line to print - char *line = (char*) malloc(end+1); // allocate a line because we modify it + char *line = (char*) malloc(end-start+1); // allocate a line because we modify it strcpy(line, original_line + start); // get a line from the right start - line[end] = '\0'; // terminate it + line[end-start] = '\0'; // terminate it mvprintw(row, 0, "%s", line); // print it - free(line); // free it } @@ -44,8 +43,13 @@ void print_current_image(struct message* msg, int start, int end) { } - void callback(const struct message *msg) { printf("in callback, tst=%d\n", msg->timestamp); + + int start; + + + print_current_image(msg, start, start+80); + }