]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/lib_cur_term.c
ncurses 6.4 - patch 20240420
[ncurses.git] / ncurses / tinfo / lib_cur_term.c
index b1303d6d45334cfdecf4d8291a39053bf689b5d5..1f8db2c1e0c8587984503ffe69b0d22b239a24f9 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020,2021 Thomas E. Dickey                                     *
+,* Copyright 2020-2021,2022 Thomas E. Dickey                                *
  * Copyright 1998-2016,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -41,7 +41,7 @@
 #include <termcap.h>           /* ospeed */
 #include <tic.h>               /* VALID_STRING */
 
-MODULE_ID("$Id: lib_cur_term.c,v 1.44 2021/11/06 19:04:21 tom Exp $")
+MODULE_ID("$Id: lib_cur_term.c,v 1.49 2022/05/28 17:56:55 tom Exp $")
 
 #undef CUR
 #define CUR TerminalType(termp).
@@ -147,7 +147,11 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
        );
 
 #if NCURSES_EXT_NUMBERS
-       _nc_free_termtype(&termp->type);
+#if NCURSES_EXT_COLORS
+       _nc_free_termtype1(&termp->type);
+#else
+       _nc_free_termtype2(&termp->type);
+#endif
 #endif
        _nc_free_termtype2(&TerminalType(termp));
        if (termp == cur)
@@ -167,6 +171,10 @@ NCURSES_SP_NAME(del_curterm) (NCURSES_SP_DCLx TERMINAL *termp)
        /* discard memory used in tgetent's cache for this terminal */
        _nc_tgetent_leak(termp);
 #endif
+       if (--_nc_globals.terminal_count == 0) {
+           _nc_free_tparm(termp);
+       }
+
        free(termp->tparm_state.fmt_buff);
        free(termp->tparm_state.out_buff);
        free(termp);