patch 8.2.3620: memory leak reported in libtlib

Problem:    Memory leak reported in libtlib.
Solution:   Call del_curterm() when cleaning up memory.  Rename term.h to
            termdefs.h to avoid a name clash.
diff --git a/src/term.c b/src/term.c
index cb38b93..52533e9 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2176,6 +2176,28 @@
     return OK;
 }
 
+#if defined(EXITFREE) || defined(PROTO)
+
+# ifdef HAVE_DEL_CURTERM
+#  undef TERMINAL	    // name clash in term.h
+#  include <term.h>	    // declares cur_term
+# endif
+
+/*
+ * If supported, delete "cur_term", which caches terminal related entries.
+ * Avoids that valgrind reports possibly lost memory.
+ */
+    void
+free_cur_term()
+{
+# ifdef HAVE_DEL_CURTERM
+    if (cur_term)
+	del_curterm(cur_term);
+# endif
+}
+
+#endif
+
 #ifdef HAVE_TGETENT
 /*
  * Call tgetent()