X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Ftest_setupterm.c;h=24d7c46c7773846b1b5c83f6ce0fc498f0182a2d;hb=b97ea58e03d5faebed2166faa4e0e590f2cdea34;hp=4e53c2e7c0cfcb54f0a5d7499821f7271a49385a;hpb=a09e8b13568e210a03ca4ad64e8552c0edea07c5;p=ncurses.git diff --git a/test/test_setupterm.c b/test/test_setupterm.c index 4e53c2e7..24d7c46c 100644 --- a/test/test_setupterm.c +++ b/test/test_setupterm.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 2020-2022,2023 Thomas E. Dickey * * Copyright 2015,2016 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: test_setupterm.c,v 1.16 2022/12/10 23:23:27 tom Exp $ + * $Id: test_setupterm.c,v 1.17 2023/06/24 14:19:52 tom Exp $ * * A simple demo of setupterm/restartterm. */ @@ -48,6 +48,13 @@ static TERMINAL **saved_terminals; static size_t num_saved; static size_t max_saved; +static void +failed(const char *msg) +{ + perror(msg); + ExitProgram(EXIT_FAILURE); +} + static void finish(int code) { @@ -73,6 +80,8 @@ save_curterm(void) if (num_saved + 1 >= max_saved) { max_saved += 100; saved_terminals = typeRealloc(TERMINAL *, max_saved, saved_terminals); + if (saved_terminals == NULL) + failed("realloc"); } saved_terminals[num_saved++] = cur_term; }