summaryrefslogtreecommitdiffstats
path: root/generic/tclStringObj.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-09-29 22:17:28 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-09-29 22:17:28 (GMT)
commit1d5b0da0c8f65eeca48341adca32a96a8774f84a (patch)
tree9a574faca8ab395bddcb8ebbfcba24f070a7296a /generic/tclStringObj.c
parente63ee140f8bf8b9c127ad90c03a516be076d6ae1 (diff)
downloadtcl-1d5b0da0c8f65eeca48341adca32a96a8774f84a.zip
tcl-1d5b0da0c8f65eeca48341adca32a96a8774f84a.tar.gz
tcl-1d5b0da0c8f65eeca48341adca32a96a8774f84a.tar.bz2
Factorize out the code for freeing an object's internal rep.
Diffstat (limited to 'generic/tclStringObj.c')
-rw-r--r--generic/tclStringObj.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c
index 106e3c4..6ed3570 100644
--- a/generic/tclStringObj.c
+++ b/generic/tclStringObj.c
@@ -33,7 +33,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStringObj.c,v 1.34 2003/12/24 04:18:20 davygrvy Exp $ */
+ * RCS: @(#) $Id: tclStringObj.c,v 1.35 2004/09/29 22:17:29 dkf Exp $ */
#include "tclInt.h"
@@ -699,8 +699,6 @@ Tcl_SetStringObj(objPtr, bytes, length)
* negative, use bytes up to the first
* NULL byte.*/
{
- register Tcl_ObjType *oldTypePtr = objPtr->typePtr;
-
/*
* Free any old string rep, then set the string rep to a copy of
* the length bytes starting at "bytes".
@@ -714,9 +712,7 @@ Tcl_SetStringObj(objPtr, bytes, length)
* Set the type to NULL and free any internal rep for the old type.
*/
- if ((oldTypePtr != NULL) && (oldTypePtr->freeIntRepProc != NULL)) {
- oldTypePtr->freeIntRepProc(objPtr);
- }
+ TclFreeIntRep(objPtr);
objPtr->typePtr = NULL;
Tcl_InvalidateStringRep(objPtr);
@@ -950,7 +946,6 @@ Tcl_SetUnicodeObj(objPtr, unicode, numChars)
int numChars; /* Number of characters in the unicode
* string. */
{
- Tcl_ObjType *typePtr;
String *stringPtr;
size_t uallocated;
@@ -966,10 +961,7 @@ Tcl_SetUnicodeObj(objPtr, unicode, numChars)
* Free the internal rep if one exists, and invalidate the string rep.
*/
- typePtr = objPtr->typePtr;
- if ((typePtr != NULL) && (typePtr->freeIntRepProc) != NULL) {
- (*typePtr->freeIntRepProc)(objPtr);
- }
+ TclFreeIntRep(objPtr);
objPtr->typePtr = &tclStringType;
/*
@@ -1813,9 +1805,7 @@ SetStringFromAny(interp, objPtr)
if (objPtr->bytes == NULL) {
objPtr->typePtr->updateStringProc(objPtr);
}
- if ((objPtr->typePtr->freeIntRepProc) != NULL) {
- (*objPtr->typePtr->freeIntRepProc)(objPtr);
- }
+ TclFreeIntRep(objPtr);
}
objPtr->typePtr = &tclStringType;