From 15a787b4fd8d5503b075058f4e2ee096eb8d1924 Mon Sep 17 00:00:00 2001 From: das Date: Fri, 6 Feb 2009 08:13:23 +0000 Subject: * generic/tkImgPhoto.c: fix numerous leaks discovered with the * generic/tkMenu.c: Mac OS X Instruments.app Leaks tool. * generic/tkText.c: * generic/tkTextImage.c: * generic/tkTextIndex.c: * generic/tkUndo.c: * generic/ttk/ttkFrame.c: * macosx/tkMacOSXWm.c: --- ChangeLog | 11 +++++++++++ generic/tkImgPhoto.c | 4 +++- generic/tkMenu.c | 11 +++++++++-- generic/tkText.c | 3 ++- generic/tkTextImage.c | 5 ++++- generic/tkTextIndex.c | 8 ++++++-- generic/tkUndo.c | 10 +++++----- generic/ttk/ttkFrame.c | 5 ++++- macosx/tkMacOSXWm.c | 8 +++++++- 9 files changed, 51 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 10569bf..5f5c36d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-02-06 Daniel Steffen + + * generic/tkImgPhoto.c: fix numerous leaks discovered with the + * generic/tkMenu.c: Mac OS X Instruments.app Leaks tool. + * generic/tkText.c: + * generic/tkTextImage.c: + * generic/tkTextIndex.c: + * generic/tkUndo.c: + * generic/ttk/ttkFrame.c: + * macosx/tkMacOSXWm.c: + 2009-01-22 Kevin B. Kenny * unix/tcl.m4: Corrected a typo ($(SHLIB_VERSION) should be diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 6d5bfec..9ffbb3d 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhoto.c,v 1.76.2.2 2009/01/14 22:59:02 nijtmans Exp $ + * RCS: @(#) $Id: tkImgPhoto.c,v 1.76.2.3 2009/02/06 08:13:23 das Exp $ */ #include "tkInt.h" @@ -2466,6 +2466,8 @@ ImgPhotoGet( WhitePixelOfScreen(Tk_Screen(tkwin)); gcValues.background = (black != NULL)? black->pixel: BlackPixelOfScreen(Tk_Screen(tkwin)); + Tk_FreeColor(white); + Tk_FreeColor(black); gcValues.graphics_exposures = False; instancePtr->gc = Tk_GetGC(tkwin, GCForeground|GCBackground|GCGraphicsExposures, &gcValues); diff --git a/generic/tkMenu.c b/generic/tkMenu.c index a402fc3..acb6ac9 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMenu.c,v 1.41 2007/12/13 15:24:15 dgp Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.41.2.1 2009/02/06 08:13:23 das Exp $ */ /* @@ -393,6 +393,13 @@ static Tk_ClassProcs menuClass = { *-------------------------------------------------------------- */ +static void +FreeOptionTables( + ClientData clientData) +{ + ckfree(clientData); +} + int TkCreateMenuCmd( Tcl_Interp *interp) /* Interpreter we are creating the command @@ -417,7 +424,7 @@ TkCreateMenuCmd( Tk_CreateOptionTable(interp, specsArray[CHECK_BUTTON_ENTRY]); Tcl_CreateObjCommand(interp, "menu", MenuCmd, - (ClientData) optionTablesPtr, NULL); + (ClientData) optionTablesPtr, FreeOptionTables); if (Tcl_IsSafe(interp)) { Tcl_HideCommand(interp, "menu", "menu"); diff --git a/generic/tkText.c b/generic/tkText.c index fb2f9b1..95d91e5 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkText.c,v 1.79.2.2 2008/12/21 23:52:45 ferrieux Exp $ + * RCS: @(#) $Id: tkText.c,v 1.79.2.3 2009/02/06 08:13:23 das Exp $ */ #include "default.h" @@ -1955,6 +1955,7 @@ DestroyText( if (sharedTextPtr->bindingTable != NULL) { Tk_DeleteBindingTable(sharedTextPtr->bindingTable); } + ckfree((char *) sharedTextPtr); } if (textPtr->tabArrayPtr != NULL) { diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c index e63b909..dcdcd35 100644 --- a/generic/tkTextImage.c +++ b/generic/tkTextImage.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextImage.c,v 1.22 2007/12/13 15:24:17 dgp Exp $ + * RCS: @(#) $Id: tkTextImage.c,v 1.22.2.1 2009/02/06 08:13:23 das Exp $ */ #include "tkPort.h" @@ -472,6 +472,9 @@ EmbImageDeleteProc( Tk_FreeConfigOptions((char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable, NULL); + if (eiPtr->body.ei.name) { + ckfree(eiPtr->body.ei.name); + } ckfree((char *) eiPtr); return 0; } diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c index 4219feb..5173e90 100644 --- a/generic/tkTextIndex.c +++ b/generic/tkTextIndex.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextIndex.c,v 1.28 2007/12/13 15:24:17 dgp Exp $ + * RCS: @(#) $Id: tkTextIndex.c,v 1.28.2.1 2009/02/06 08:13:23 das Exp $ */ #include "default.h" @@ -113,9 +113,13 @@ DupTextIndexInternalRep( dupIndexPtr->tree = indexPtr->tree; dupIndexPtr->linePtr = indexPtr->linePtr; dupIndexPtr->byteIndex = indexPtr->byteIndex; - + dupIndexPtr->textPtr = indexPtr->textPtr; + if (dupIndexPtr->textPtr != NULL) { + dupIndexPtr->textPtr->refCount++; + } SET_TEXTINDEX(copyPtr, dupIndexPtr); SET_INDEXEPOCH(copyPtr, epoch); + copyPtr->typePtr = &tkTextIndexType; } /* diff --git a/generic/tkUndo.c b/generic/tkUndo.c index e875bf3..326c818 100644 --- a/generic/tkUndo.c +++ b/generic/tkUndo.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkUndo.c,v 1.13 2007/12/13 15:24:21 dgp Exp $ + * RCS: @(#) $Id: tkUndo.c,v 1.13.2.1 2009/02/06 08:13:23 das Exp $ */ #include "tkInt.h" @@ -131,7 +131,7 @@ TkUndoClearStack( TkUndoSubAtom *sub; sub = elem->apply; - while (sub->next != NULL) { + while (sub != NULL) { TkUndoSubAtom *next = sub->next; if (sub->action != NULL) { @@ -142,7 +142,7 @@ TkUndoClearStack( } sub = elem->revert; - while (sub->next != NULL) { + while (sub != NULL) { TkUndoSubAtom *next = sub->next; if (sub->action != NULL) { @@ -399,7 +399,7 @@ TkUndoSetDepth( prevelem = elem; if (elem->type != TK_UNDO_SEPARATOR) { TkUndoSubAtom *sub = elem->apply; - while (sub->next != NULL) { + while (sub != NULL) { TkUndoSubAtom *next = sub->next; if (sub->action != NULL) { @@ -409,7 +409,7 @@ TkUndoSetDepth( sub = next; } sub = elem->revert; - while (sub->next != NULL) { + while (sub != NULL) { TkUndoSubAtom *next = sub->next; if (sub->action != NULL) { diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index c0f5ed6..e7e3ca6 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -1,4 +1,4 @@ -/* $Id: ttkFrame.c,v 1.12 2008/01/08 20:02:27 jenglish Exp $ +/* $Id: ttkFrame.c,v 1.12.2.1 2009/02/06 08:13:23 das Exp $ * Copyright (c) 2004, Joe English * * ttk::frame and ttk::labelframe widgets. @@ -535,6 +535,9 @@ static void LabelframeCleanup(void *recordPtr) { Labelframe *lframe = recordPtr; Ttk_DeleteManager(lframe->label.mgr); + if (lframe->label.labelLayout) { + Ttk_FreeLayout(lframe->label.labelLayout); + } } /* RaiseLabelWidget -- diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 88e49fe..dd9b93e 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXWm.c,v 1.63.2.2 2008/11/15 00:37:30 patthoyts Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.63.2.3 2009/02/06 08:13:23 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -426,6 +426,9 @@ TkWmDeadWindow( if (wmPtr->hints.flags & IconMaskHint) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } + if (wmPtr->iconName != NULL) { + ckfree(wmPtr->iconName); + } if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } @@ -2960,6 +2963,9 @@ WmTransientCmd( argv3 = Tcl_GetStringFromObj(objv[3], &length); wmPtr->master = Tk_WindowId(master); + if (wmPtr->masterWindowName != NULL) { + ckfree(wmPtr->masterWindowName); + } wmPtr->masterWindowName = ckalloc((unsigned) length+1); strcpy(wmPtr->masterWindowName, argv3); } -- cgit v0.12