X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=src%2Fgridtest.c;h=cec6004344bd8c74d32a158f996b2ca70145859d;hb=91214934fbcdfd363202a65c142194506604ff7b;hp=92d3d0cddafd1402aeef9f316371665258da4cd3;hpb=3fa6fa06001573550f76699d7f89be5a9c4d9f90;p=projects%2Fchimara%2Fchimara.git diff --git a/src/gridtest.c b/src/gridtest.c index 92d3d0c..cec6004 100644 --- a/src/gridtest.c +++ b/src/gridtest.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include "glk.h" void glk_main(void) @@ -17,7 +19,7 @@ void glk_main(void) for(count = 0; count < 30; count++) glk_put_string("I want to write past the end of this text buffer! "); - guint32 width, height; + glui32 width, height; glk_window_get_size(mainwin, &width, &height); fprintf(stderr, "\nWidth: %d\nHeight: %d\nPress a key in the window, not in the terminal.\n", width, height); glk_request_char_event(mainwin); @@ -43,7 +45,8 @@ void glk_main(void) break; } - gchar *buffer = g_malloc0(256); + char *buffer = calloc(256, sizeof(char)); + assert(buffer); fprintf(stderr, "Line input field until end of line\n"); glk_window_move_cursor(mainwin, 10, 20); @@ -63,7 +66,12 @@ void glk_main(void) break; } - fprintf(stderr, "Your string was: '%s'.\nPress another key to clear the window and exit.\n", buffer); + char *text = calloc(ev.val1 + 1, sizeof(char)); + assert(text); + strncpy(text, buffer, ev.val1); + text[ev.val1] = '\0'; + fprintf(stderr, "Your string was: '%s'.\nPress another key to clear the window and exit.\n", text); + free(text); glk_request_char_event(mainwin); while(1) { glk_select(&ev); @@ -72,5 +80,5 @@ void glk_main(void) } glk_window_clear(mainwin); - g_free(buffer); -} \ No newline at end of file + free(buffer); +}