From abc17d37aa9ce22e2599d842ed8d32474c832a7c Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 11 Jan 2020 21:45:27 -0500 Subject: [PATCH] ncplane_vprintf_prep: reprint after realloc #260 --- src/lib/notcurses.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/notcurses.c b/src/lib/notcurses.c index 9a508d5b7..53e7ada5c 100644 --- a/src/lib/notcurses.c +++ b/src/lib/notcurses.c @@ -671,6 +671,11 @@ ffmpeg_log_level(ncloglevel_e level){ } notcurses* notcurses_init(const notcurses_options* opts, FILE* outfp){ + notcurses_options defaultopts; + memset(&defaultopts, 0, sizeof(defaultopts)); + if(!opts){ + opts = &defaultopts; + } const char* encoding = nl_langinfo(CODESET); if(encoding == NULL || strcmp(encoding, "UTF-8")){ fprintf(stderr, "Encoding (\"%s\") wasn't UTF-8, refusing to start\n", @@ -1248,7 +1253,8 @@ unsigned ncplane_styles(ncplane* n){ // i hate the big allocation and two copies here, but eh what you gonna do? // well, for one, we don't need the huge allocation FIXME -char* ncplane_vprintf_prep(ncplane* n, const char* format, va_list ap){ +static char* +ncplane_vprintf_prep(ncplane* n, const char* format, va_list ap){ const size_t size = n->lenx + 1; // healthy estimate, can embiggen below char* buf = malloc(size); if(buf == NULL){ @@ -1266,6 +1272,7 @@ char* ncplane_vprintf_prep(ncplane* n, const char* format, va_list ap){ return NULL; } buf = tmp; + vsprintf(buf, format, ap); } return buf; }