summaryrefslogtreecommitdiffstats
path: root/generic/tkFont.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2009-11-21 17:24:42 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2009-11-21 17:24:42 (GMT)
commit3e32b5193302ae1a6fe572b1abfb23236d62eceb (patch)
tree2f3caa27961649ffb0b7e55228284889014f5c1c /generic/tkFont.c
parentd610ac08ec4c694f1fd4be42eafce064c3f9d40a (diff)
downloadtk-3e32b5193302ae1a6fe572b1abfb23236d62eceb.zip
tk-3e32b5193302ae1a6fe572b1abfb23236d62eceb.tar.gz
tk-3e32b5193302ae1a6fe572b1abfb23236d62eceb.tar.bz2
[Tcl Bug 2857044]: Corrections following audit of Tcl_ObjType freeing
practises; the typePtr field is now cleared when an object ceases to be of the type. Also remove some anachronistic techniques (pointless casts, mixed assignments and tests, etc.)
Diffstat (limited to 'generic/tkFont.c')
-rw-r--r--generic/tkFont.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/generic/tkFont.c b/generic/tkFont.c
index ebd2e3a..21368fc 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.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: tkFont.c,v 1.60 2009/10/21 21:22:26 patthoyts Exp $
+ * RCS: @(#) $Id: tkFont.c,v 1.61 2009/11/21 17:24:42 dkf Exp $
*/
#include "tkInt.h"
@@ -329,6 +329,7 @@ static int ConfigAttributesObj(Tcl_Interp *interp,
TkFontAttributes *faPtr);
static void DupFontObjProc(Tcl_Obj *srcObjPtr, Tcl_Obj *dupObjPtr);
static int FieldSpecified(const char *field);
+static void FreeFontObj(Tcl_Obj *objPtr);
static void FreeFontObjProc(Tcl_Obj *objPtr);
static int GetAttributeInfoObj(Tcl_Interp *interp,
const TkFontAttributes *faPtr, Tcl_Obj *objPtr);
@@ -1117,7 +1118,7 @@ Tk_AllocFontFromObj(
* longer in use. Clear the reference.
*/
- FreeFontObjProc(objPtr);
+ FreeFontObj(objPtr);
oldFontPtr = NULL;
} else if (Tk_Screen(tkwin) == oldFontPtr->screen) {
oldFontPtr->resourceRefCount++;
@@ -1133,7 +1134,7 @@ Tk_AllocFontFromObj(
isNew = 0;
if (oldFontPtr != NULL) {
cacheHashPtr = oldFontPtr->cacheHashPtr;
- FreeFontObjProc(objPtr);
+ FreeFontObj(objPtr);
} else {
cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache,
Tcl_GetString(objPtr), &isNew);
@@ -1297,7 +1298,7 @@ Tk_GetFontFromObj(
* longer in use. Clear the reference.
*/
- FreeFontObjProc(objPtr);
+ FreeFontObj(objPtr);
fontPtr = NULL;
} else if (Tk_Screen(tkwin) == fontPtr->screen) {
return (Tk_Font) fontPtr;
@@ -1311,7 +1312,7 @@ Tk_GetFontFromObj(
if (fontPtr != NULL) {
hashPtr = fontPtr->cacheHashPtr;
- FreeFontObjProc(objPtr);
+ FreeFontObj(objPtr);
} else {
hashPtr = Tcl_FindHashEntry(&fiPtr->fontCache, Tcl_GetString(objPtr));
}
@@ -1495,7 +1496,7 @@ Tk_FreeFontFromObj(
/*
*---------------------------------------------------------------------------
*
- * FreeFontObjProc --
+ * FreeFontObjProc, FreeFontObj --
*
* This proc is called to release an object reference to a font. Called
* when the object's internal rep is released or when the cached fontPtr
@@ -1515,6 +1516,14 @@ static void
FreeFontObjProc(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
+ FreeFontObj(objPtr);
+ objPtr->typePtr = NULL;
+}
+
+static void
+FreeFontObj(
+ Tcl_Obj *objPtr) /* The object we are releasing. */
+{
TkFont *fontPtr = objPtr->internalRep.twoPtrValue.ptr1;
if (fontPtr != NULL) {