From 76e883da5646c90946512d237df48377778d63cc Mon Sep 17 00:00:00 2001 From: das Date: Fri, 6 Feb 2009 08:12:06 +0000 Subject: * generic/tkImgPhInstance.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/tkUtil.c: * generic/ttk/ttkFrame.c: * macosx/tkMacOSXWm.c: --- ChangeLog | 12 ++++++++++++ generic/tkImgPhInstance.c | 4 +++- generic/tkMenu.c | 12 ++++++++++-- generic/tkText.c | 3 ++- generic/tkTextImage.c | 5 ++++- generic/tkTextIndex.c | 8 ++++++-- generic/tkUndo.c | 10 +++++----- generic/tkUtil.c | 8 +++++--- generic/ttk/ttkFrame.c | 5 ++++- macosx/tkMacOSXWm.c | 8 +++++++- 10 files changed, 58 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22b8f21..1d69c4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-02-06 Daniel Steffen + + * generic/tkImgPhInstance.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/tkUtil.c: + * generic/ttk/ttkFrame.c: + * macosx/tkMacOSXWm.c: + 2009-01-29 Jan Nijtmans * generic/tkCanvArc.c - eliminate some unnessary type casts diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c index 1b0395e..07fa0c0 100644 --- a/generic/tkImgPhInstance.c +++ b/generic/tkImgPhInstance.c @@ -17,7 +17,7 @@ * Department of Computer Science, * Australian National University. * - * RCS: @(#) $Id: tkImgPhInstance.c,v 1.1 2008/08/25 11:44:04 dkf Exp $ + * RCS: @(#) $Id: tkImgPhInstance.c,v 1.2 2009/02/06 08:12:07 das Exp $ */ #include "tkImgPhoto.h" @@ -350,6 +350,8 @@ TkImgPhotoGet( 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 3d2aa39..fa2959f 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.49 2009/01/14 22:48:10 nijtmans Exp $ + * RCS: @(#) $Id: tkMenu.c,v 1.50 2009/02/06 08:12:07 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 @@ -416,7 +423,8 @@ TkCreateMenuCmd( optionTablesPtr->entryOptionTables[CHECK_BUTTON_ENTRY] = Tk_CreateOptionTable(interp, specsArray[CHECK_BUTTON_ENTRY]); - Tcl_CreateObjCommand(interp, "menu", MenuCmd, optionTablesPtr, NULL); + Tcl_CreateObjCommand(interp, "menu", MenuCmd, optionTablesPtr, + FreeOptionTables); if (Tcl_IsSafe(interp)) { Tcl_HideCommand(interp, "menu", "menu"); diff --git a/generic/tkText.c b/generic/tkText.c index c7c5418..4e605ce 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.88 2009/02/03 23:55:47 nijtmans Exp $ + * RCS: @(#) $Id: tkText.c,v 1.89 2009/02/06 08:12:07 das Exp $ */ #include "default.h" @@ -1968,6 +1968,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 6f38943..d0572b0 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.25 2008/10/30 23:18:59 nijtmans Exp $ + * RCS: @(#) $Id: tkTextImage.c,v 1.26 2009/02/06 08:12:07 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 3631cf5..05459cd 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.34 2008/12/05 15:51:31 nijtmans Exp $ + * RCS: @(#) $Id: tkTextIndex.c,v 1.35 2009/02/06 08:12:07 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 ceb6e51..8371f04 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.14 2008/11/08 18:44:40 dkf Exp $ + * RCS: @(#) $Id: tkUndo.c,v 1.15 2009/02/06 08:12:07 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/tkUtil.c b/generic/tkUtil.c index 5218740..3c3b5f8 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.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: tkUtil.c,v 1.27 2008/12/10 05:02:51 das Exp $ + * RCS: @(#) $Id: tkUtil.c,v 1.28 2009/02/06 08:12:07 das Exp $ */ #include "tkInt.h" @@ -1084,7 +1084,7 @@ TkMakeEnsemble( { Tcl_Namespace *namespacePtr = NULL; Tcl_Command ensemble = NULL; - Tcl_Obj *dictObj = NULL; + Tcl_Obj *dictObj = NULL, *nameObj; Tcl_DString ds; int i; @@ -1102,7 +1102,9 @@ TkMakeEnsemble( } } - ensemble = Tcl_FindEnsemble(interp, Tcl_NewStringObj(name,-1), 0); + nameObj = Tcl_NewStringObj(name, -1); + ensemble = Tcl_FindEnsemble(interp, nameObj, 0); + Tcl_DecrRefCount(nameObj); if (ensemble == NULL) { ensemble = Tcl_CreateEnsemble(interp, name, namespacePtr, TCL_ENSEMBLE_PREFIX); diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index f7ac834..f7edfe3 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -1,4 +1,4 @@ -/* $Id: ttkFrame.c,v 1.13 2008/11/09 23:53:09 jenglish Exp $ +/* $Id: ttkFrame.c,v 1.14 2009/02/06 08:12:07 das Exp $ * Copyright (c) 2004, Joe English * * ttk::frame and ttk::labelframe widgets. @@ -533,6 +533,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 96605c8..94fa8ba 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.73 2008/12/07 16:36:26 das Exp $ + * RCS: @(#) $Id: tkMacOSXWm.c,v 1.74 2009/02/06 08:12:07 das Exp $ */ #include "tkMacOSXPrivate.h" @@ -465,6 +465,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); } @@ -2998,6 +3001,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