diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-09-29 22:17:28 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-09-29 22:17:28 (GMT) |
commit | 1d5b0da0c8f65eeca48341adca32a96a8774f84a (patch) | |
tree | 9a574faca8ab395bddcb8ebbfcba24f070a7296a /generic/tclRegexp.c | |
parent | e63ee140f8bf8b9c127ad90c03a516be076d6ae1 (diff) | |
download | tcl-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/tclRegexp.c')
-rw-r--r-- | generic/tclRegexp.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/generic/tclRegexp.c b/generic/tclRegexp.c index 3d67fcb..f764bec 100644 --- a/generic/tclRegexp.c +++ b/generic/tclRegexp.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: tclRegexp.c,v 1.15 2004/04/06 22:25:54 dgp Exp $ + * RCS: @(#) $Id: tclRegexp.c,v 1.16 2004/09/29 22:17:30 dkf Exp $ */ #include "tclInt.h" @@ -565,10 +565,13 @@ Tcl_GetRegExpFromObj(interp, objPtr, flags) TclRegexp *regexpPtr; char *pattern; - typePtr = objPtr->typePtr; + /* + * This is OK because we only actually interpret this value + * properly as a TclRegexp* when the type is tclRegexpType. + */ regexpPtr = (TclRegexp *) objPtr->internalRep.otherValuePtr; - if ((typePtr != &tclRegexpType) || (regexpPtr->flags != flags)) { + if ((objPtr->typePtr != &tclRegexpType) || (regexpPtr->flags != flags)) { pattern = Tcl_GetStringFromObj(objPtr, &length); regexpPtr = CompileRegexp(interp, pattern, length, flags); @@ -588,9 +591,7 @@ Tcl_GetRegExpFromObj(interp, objPtr, flags) * Free the old representation and set our type. */ - if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { - (*typePtr->freeIntRepProc)(objPtr); - } + TclFreeIntRep(objPtr); objPtr->internalRep.otherValuePtr = (VOID *) regexpPtr; objPtr->typePtr = &tclRegexpType; } |