slang-users mailing list

[2007 Date Index] [2007 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Memory leak in SLtt_get_terminfo


Hi,

a memory leak occurs when SLtt_get_terminfo function is called
repeatedly as data allocated in _pSLtt_tigetent are lost.

Attached is a patch that deletes the old entry when a new entry is
requested, that should at least keep the size of the leak constant.

-- 
Miroslav Lichvar
Index: src/sldisply.c
===================================================================
--- src/sldisply.c	(revision 116)
+++ src/sldisply.c	(working copy)
@@ -2374,6 +2374,8 @@
 		   || !strcmp (term, "screen"));
 
 # ifndef USE_TERMCAP
+   if (NULL != Terminfo)
+     _pSLtt_tifreeent (Terminfo);
    if (NULL == (Terminfo = _pSLtt_tigetent (term)))
      {
 	if (almost_vtxxx) /* Special cases. */
Index: src/sltermin.c
===================================================================
--- src/sltermin.c	(revision 116)
+++ src/sltermin.c	(working copy)
@@ -347,6 +347,16 @@
    return NULL;
 }
 
+void _pSLtt_tifreeent (SLterminfo_Type *t)
+{
+   SLfree ((char *)t->string_table);
+   SLfree ((char *)t->string_offsets);
+   SLfree ((char *)t->numbers);
+   SLfree ((char *)t->boolean_flags);
+   SLfree ((char *)t->terminal_names);
+   SLfree ((char *)t);
+}
+
 #ifdef SLANG_UNTIC
 # define UNTIC_COMMENT(x) ,x
 #else





[2007 date index] [2007 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]