diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2009-11-09 11:56:56 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2009-11-09 11:56:56 (GMT) |
commit | 55f7e0cf3aa4d25e8c0b84f1eb98b514a7160818 (patch) | |
tree | 403da685039abe38dc8649c1ebf94daae52f2b0f | |
parent | 2193dc0fe95f1b7b0b072e048b11f73a0844059f (diff) | |
download | tk-55f7e0cf3aa4d25e8c0b84f1eb98b514a7160818.zip tk-55f7e0cf3aa4d25e8c0b84f1eb98b514a7160818.tar.gz tk-55f7e0cf3aa4d25e8c0b84f1eb98b514a7160818.tar.bz2 |
Some code consolidation (don't scatter deletion code where unnecessary).
-rw-r--r-- | ChangeLog | 43 | ||||
-rw-r--r-- | generic/tkFileFilter.c | 154 |
2 files changed, 67 insertions, 130 deletions
@@ -1,3 +1,9 @@ +2009-11-09 Donal K. Fellows <dkf@users.sf.net> + + * generic/tkFileFilter.c (TkFreeFileFilters): Simplify the code in + this file by consolidating the deletion code together into a single + function rather than scattering it over four. + 2009-11-01 Joe Mistachkin <joe@mistachkin.com> * win/tkWinButton.c: [Bug 1739613]: The default width being stored @@ -7,28 +13,27 @@ 2009-11-01 Joe Mistachkin <joe@mistachkin.com> - * doc/loadTk.n: minor fix for htmlhelp target. + * doc/loadTk.n: Minor fix for htmlhelp target. 2009-11-01 Joe English <jenglish@users.sourceforge.net> - * generic/ttk/ttkWidget.c, doc/ttk_widget.n: - Uniform, extensible syntax for [$w identify] methods: - [$w identify $component $x $y]. All ttk::* widgets support - [$w identify element $x $y]; widgets with other + * generic/ttk/ttkWidget.c, doc/ttk_widget.n: Uniform, extensible + syntax for [$w identify] methods: [$w identify $component $x $y]. All + ttk::* widgets support [$w identify element $x $y]; widgets with other identifiable parts may have additional subcommands. - * generic/ttk/ttkNotebook.c, doc/ttk_notebook.n: - Notebook widgets support [$nb identify tab]. - * generic/ttk/ttkPanedwindow.c, doc/ttk_panedwindow.n: - Panedwindow widgets support [$w identify sash]. - Older 2-argument form [$w identify $x $y] still supported, - though it does different things depending on the widget. + * generic/ttk/ttkNotebook.c, doc/ttk_notebook.n: Notebook widgets + support [$nb identify tab]. + * generic/ttk/ttkPanedwindow.c, doc/ttk_panedwindow.n: Panedwindow + widgets support [$w identify sash]. Older 2-argument form [$w + identify $x $y] still supported, though it does different things + depending on the widget. 2009-10-29 Pat Thoyts <patthoyts@users.sourceforge.net> * win/tkWinFont.c: [Bug 1825353]: This patch reverts a previous - attempt to fix tiny fonts on Russian Windows. It fixes the - issue by requesting a suitable fixed font instead of decoding the - system stock font. + attempt to fix tiny fonts on Russian Windows. It fixes the issue by + requesting a suitable fixed font instead of decoding the system stock + font. 2009-10-26 Don Porter <dgp@users.sourceforge.net> @@ -54,18 +59,18 @@ 2009-10-22 Donal K. Fellows <dkf@users.sf.net> * generic/tkText.c (CreateWidget, TextEditUndo, TextEditRedo) - (TextEditCmd, UpdateDirtyFlag): + (TextEditCmd, UpdateDirtyFlag): * generic/tkText.h: [Patch 1469210]: Corrected handling of marking as dirty when inserting after an undo from a non-dirty state. * win/tkWinDialog.c (GetFileNameA): Make the handling of the filter index the same as in GetFileNameW. - * library/tkfbox.tcl (::tk::dialog::file::, Done): + * library/tkfbox.tcl (::tk::dialog::file::, Done): * library/xmfbox.tcl (MotifFDialog_FileTypes) - (MotifFDialog_ActivateSEnt): - * macosx/tkMacOSXDialog.c (Tk_GetOpenFileObjCmd): - * win/tkWinDialog.c (GetFileNameW, GetFileNameA): + (MotifFDialog_ActivateSEnt): + * macosx/tkMacOSXDialog.c (Tk_GetOpenFileObjCmd): + * win/tkWinDialog.c (GetFileNameW, GetFileNameA): * doc/getOpenFile.n: [Patch 2168768]: Corrected handling of the -typevariable option to be consistently global; it's the only way it can work even close to the same on all platforms. diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c index 4e355d4..b8e8101 100644 --- a/generic/tkFileFilter.c +++ b/generic/tkFileFilter.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: tkFileFilter.c,v 1.12 2008/12/07 16:34:12 das Exp $ + * RCS: @(#) $Id: tkFileFilter.c,v 1.13 2009/11/09 11:56:57 dkf Exp $ */ #include "tkInt.h" @@ -18,9 +18,6 @@ static int AddClause(Tcl_Interp *interp, FileFilter *filterPtr, Tcl_Obj *patternsObj, Tcl_Obj *ostypesObj, int isWindows); -static void FreeClauses(FileFilter *filterPtr); -static void FreeGlobPatterns(FileFilterClause *clausePtr); -static void FreeMacFileTypes(FileFilterClause *clausePtr); static FileFilter * GetFilter(FileFilterList *flistPtr, const char *name); /* @@ -89,7 +86,7 @@ TkGetFileFilters( int i; if (types == NULL) { - return TCL_OK; + return TCL_OK; } if (Tcl_ListObjGetElements(interp, types, &listObjc, @@ -105,6 +102,7 @@ TkGetFileFilters( * the -filefilters option may have been used more than once in the * command line. */ + TkFreeFileFilters(flistPtr); for (i = 0; i<listObjc; i++) { @@ -162,15 +160,47 @@ void TkFreeFileFilters( FileFilterList *flistPtr) /* List of file filters to free */ { - FileFilter *filterPtr, *toFree; + FileFilter *filterPtr; + FileFilterClause *clausePtr; + GlobPattern *globPtr; + MacFileType *mfPtr; + register void *toFree; /* A pointer that we are about to free. */ + + for (filterPtr = flistPtr->filters; filterPtr != NULL; ) { + for (clausePtr = filterPtr->clauses; clausePtr != NULL; ) { + /* + * Squelch each of the glob patterns. + */ + + for (globPtr = clausePtr->patterns; globPtr != NULL; ) { + ckfree(globPtr->pattern); + toFree = globPtr; + globPtr = globPtr->next; + ckfree(toFree); + } + + /* + * Squelch each of the Mac file type codes. + */ + + for (mfPtr = clausePtr->macTypes; mfPtr != NULL; ) { + toFree = mfPtr; + mfPtr = mfPtr->next; + ckfree(toFree); + } + toFree = clausePtr; + clausePtr = clausePtr->next; + ckfree(toFree); + } + + /* + * Squelch the name of the filter and the overall structure. + */ - filterPtr=flistPtr->filters; - while (filterPtr != NULL) { + ckfree(filterPtr->name); toFree = filterPtr; filterPtr = filterPtr->next; - FreeClauses(toFree); - ckfree(toFree->name); - ckfree((char *) toFree); + ckfree(toFree); } flistPtr->filters = NULL; } @@ -417,8 +447,8 @@ GetFilter( filterPtr = (FileFilter *) ckalloc(sizeof(FileFilter)); filterPtr->clauses = NULL; filterPtr->clausesTail = NULL; - len = (strlen(name) + 1) * sizeof(char); - filterPtr->name = ckalloc(len); + len = strlen(name) + 1; + filterPtr->name = ckalloc((unsigned) len); memcpy(filterPtr->name, name, len); if (flistPtr->filters == NULL) { @@ -434,104 +464,6 @@ GetFilter( } /* - *---------------------------------------------------------------------- - * - * FreeClauses -- - * - * Frees the malloc'ed file type clause. - * - * Results: - * None. - * - * Side effects: - * The list of clauses in filterPtr->clauses are freed. - * - *---------------------------------------------------------------------- - */ - -static void -FreeClauses( - FileFilter *filterPtr) /* FileFilter whose clauses are to be freed */ -{ - FileFilterClause *clausePtr = filterPtr->clauses; - - while (clausePtr != NULL) { - FileFilterClause *toFree = clausePtr; - - clausePtr = clausePtr->next; - FreeGlobPatterns(toFree); - FreeMacFileTypes(toFree); - ckfree((char *) toFree); - } - filterPtr->clauses = NULL; - filterPtr->clausesTail = NULL; -} - -/* - *---------------------------------------------------------------------- - * - * FreeGlobPatterns -- - * - * Frees the malloc'ed glob patterns in a clause - * - * Results: - * None. - * - * Side effects: - * The list of glob patterns in clausePtr->patterns are freed. - * - *---------------------------------------------------------------------- - */ - -static void -FreeGlobPatterns( - FileFilterClause *clausePtr)/* The clause whose patterns are to be freed*/ -{ - GlobPattern *globPtr = clausePtr->patterns; - - while (globPtr != NULL) { - GlobPattern *toFree = globPtr; - globPtr = globPtr->next; - - ckfree(toFree->pattern); - ckfree((char *) toFree); - } - clausePtr->patterns = NULL; -} - -/* - *---------------------------------------------------------------------- - * - * FreeMacFileTypes -- - * - * Frees the malloc'ed Mac file types in a clause - * - * Results: - * None. - * - * Side effects: - * The list of Mac file types in clausePtr->macTypes are freed. - * - *---------------------------------------------------------------------- - */ - -static void -FreeMacFileTypes( - FileFilterClause *clausePtr)/* The clause whose mac types are to be - * freed. */ -{ - MacFileType *mfPtr = clausePtr->macTypes; - - while (mfPtr != NULL) { - MacFileType *toFree = mfPtr; - - mfPtr = mfPtr->next; - ckfree((char *) toFree); - } - clausePtr->macTypes = NULL; -} - -/* * Local Variables: * mode: c * c-basic-offset: 4 |