Index: ChangeLog
===================================================================
RCS file: /cvsroot/tcl/tcl/ChangeLog,v
retrieving revision 1.4752
diff -b -u -r1.4752 ChangeLog
--- ChangeLog	30 Sep 2009 03:11:24 -0000	1.4752
+++ ChangeLog	2 Oct 2009 17:41:56 -0000
@@ -1,3 +1,10 @@
+
+2009-10-02  Joe Mistachkin  <joe@mistachkin.com>
+
+	* generic/tclObj.c: [Bug 2871908]: Plug memory leaks of the objThreadMap
+	and lineCLPtr hashtables.  Also make the names of the continuation line
+	information initialization and finalization functions more consistent.
+
 2009-09-29  Don Porter  <dgp@users.sourceforge.net>
 
 	* generic/tclDictObj.c:		Updated freeIntRepProc routines so
Index: generic/tclObj.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclObj.c,v
retrieving revision 1.161
diff -b -u -r1.161 tclObj.c
--- generic/tclObj.c	30 Sep 2009 03:11:26 -0000	1.161
+++ generic/tclObj.c	2 Oct 2009 17:42:04 -0000
@@ -105,8 +105,8 @@
 static Tcl_ThreadDataKey dataKey;
 
 static void ContLineLocFree (char* clientData);
-static void TclThreadFinalizeObjects (ClientData clientData);
-static ThreadSpecificData* TclGetTables (void);
+static void TclThreadFinalizeContLines (ClientData clientData);
+static ThreadSpecificData* TclGetContLineTable (void);
 
 /*
  * Nested Tcl_Obj deletion management support
@@ -455,7 +455,7 @@
 #if defined(TCL_MEM_DEBUG) && defined(TCL_THREADS)
     Tcl_HashEntry *hPtr;
     Tcl_HashSearch hSearch;
-    ThreadSpecificData *tsdPtr = TclGetTables();
+    ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
     Tcl_HashTable *tablePtr = tsdPtr->objThreadMap;
 
     if (tablePtr != NULL) {
@@ -515,7 +515,7 @@
 /*
  *----------------------------------------------------------------------
  *
- * TclGetTables --
+ * TclGetContLineTable --
  *
  *	This procedure is a helper which returns the thread-specific
  *	hash-table used to track continuation line information associated with
@@ -532,7 +532,7 @@
  */
 
 static ThreadSpecificData*
-TclGetTables()
+TclGetContLineTable()
 {
     /*
      * Initialize the hashtable tracking invisible continuation lines.  For
@@ -546,10 +546,7 @@
     if (!tsdPtr->lineCLPtr) {
 	tsdPtr->lineCLPtr = (Tcl_HashTable*) ckalloc (sizeof (Tcl_HashTable));
 	Tcl_InitHashTable(tsdPtr->lineCLPtr, TCL_ONE_WORD_KEYS);
-	Tcl_CreateThreadExitHandler (TclThreadFinalizeObjects,NULL);
-#if defined(TCL_MEM_DEBUG) && defined(TCL_THREADS)
-	tsdPtr->objThreadMap = NULL;
-#endif /* TCL_MEM_DEBUG && TCL_THREADS */
+	Tcl_CreateThreadExitHandler (TclThreadFinalizeContLines,NULL);
     }
     return tsdPtr;
 }
@@ -578,7 +575,7 @@
 		      int* loc)
 {
     int newEntry;
-    ThreadSpecificData *tsdPtr = TclGetTables();
+    ThreadSpecificData *tsdPtr = TclGetContLineTable();
     Tcl_HashEntry* hPtr =
 	Tcl_CreateHashEntry (tsdPtr->lineCLPtr, (char*) objPtr, &newEntry);
 
@@ -709,7 +706,7 @@
 void
 TclContinuationsCopy(Tcl_Obj* objPtr, Tcl_Obj* originObjPtr)
 {
-    ThreadSpecificData *tsdPtr = TclGetTables();
+    ThreadSpecificData *tsdPtr = TclGetContLineTable();
     Tcl_HashEntry* hPtr = Tcl_FindHashEntry (tsdPtr->lineCLPtr, (char*) originObjPtr);
 
     if (hPtr) {
@@ -741,7 +738,7 @@
 ContLineLoc*
 TclContinuationsGet(Tcl_Obj* objPtr)
 {
-    ThreadSpecificData *tsdPtr = TclGetTables();
+    ThreadSpecificData *tsdPtr = TclGetContLineTable();
     Tcl_HashEntry* hPtr = Tcl_FindHashEntry (tsdPtr->lineCLPtr, (char*) objPtr);
 
     if (hPtr) {
@@ -754,7 +751,7 @@
 /*
  *----------------------------------------------------------------------
  *
- * TclThreadFinalizeObjects --
+ * TclThreadFinalizeContLines --
  *
  *	This procedure is a helper which releases all continuation line
  *	information currently known. It is run as a thread exit handler.
@@ -770,15 +767,15 @@
  */
 
 static void
-TclThreadFinalizeObjects (ClientData clientData)
+TclThreadFinalizeContLines (ClientData clientData)
 {
     /*
      * Release the hashtable tracking invisible continuation lines.
      */
 
+    ThreadSpecificData *tsdPtr = TclGetContLineTable();
     Tcl_HashEntry *hPtr;
     Tcl_HashSearch hSearch;
-    ThreadSpecificData *tsdPtr = TclGetTables();
 
     for (hPtr = Tcl_FirstHashEntry(tsdPtr->lineCLPtr, &hSearch);
 	 hPtr != NULL;
@@ -793,6 +790,7 @@
 	Tcl_DeleteHashEntry (hPtr);
     }
     Tcl_DeleteHashTable (tsdPtr->lineCLPtr);
+    ckfree((char *) tsdPtr->lineCLPtr);
     tsdPtr->lineCLPtr = NULL;
 }
 
@@ -1011,7 +1009,7 @@
     Tcl_HashSearch hSearch;
     Tcl_HashEntry *hPtr;
     Tcl_HashTable *tablePtr;
-    ThreadSpecificData *tsdPtr = TclGetTables();
+    ThreadSpecificData *tsdPtr = TclGetContLineTable();
 
     tablePtr = tsdPtr->objThreadMap;
 
@@ -1078,7 +1076,7 @@
 	Tcl_HashTable *tablePtr;
 	int isNew;
 	ObjData *objData;
-	ThreadSpecificData *tsdPtr = TclGetTables();
+	ThreadSpecificData *tsdPtr = TclGetContLineTable();
 
 	if (tsdPtr->objThreadMap == NULL) {
 	    tsdPtr->objThreadMap = (Tcl_HashTable *)
@@ -3646,7 +3644,7 @@
     if (!TclInExit()) {
 	Tcl_HashTable *tablePtr;
 	Tcl_HashEntry *hPtr;
-	ThreadSpecificData *tsdPtr = TclGetTables();
+	ThreadSpecificData *tsdPtr = TclGetContLineTable();
 
 	tablePtr = tsdPtr->objThreadMap;
 	if (!tablePtr) {
@@ -3711,7 +3709,7 @@
     if (!TclInExit()) {
 	Tcl_HashTable *tablePtr;
 	Tcl_HashEntry *hPtr;
-	ThreadSpecificData *tsdPtr = TclGetTables();
+	ThreadSpecificData *tsdPtr = TclGetContLineTable();
 
 	tablePtr = tsdPtr->objThreadMap;
 	if (!tablePtr) {
@@ -3791,7 +3789,7 @@
     if (!TclInExit()) {
 	Tcl_HashTable *tablePtr;
 	Tcl_HashEntry *hPtr;
-	ThreadSpecificData *tsdPtr = TclGetTables();
+	ThreadSpecificData *tsdPtr = TclGetContLineTable();
 	tablePtr = tsdPtr->objThreadMap;
 	if (!tablePtr) {
 	    Tcl_Panic("object table not initialized");
