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/tclBinary.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/tclBinary.c')
-rw-r--r-- | generic/tclBinary.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/generic/tclBinary.c b/generic/tclBinary.c index 44fb2f0..28f83ad 100644 --- a/generic/tclBinary.c +++ b/generic/tclBinary.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: tclBinary.c,v 1.18 2004/05/13 10:12:55 dkf Exp $ + * RCS: @(#) $Id: tclBinary.c,v 1.19 2004/09/29 22:17:33 dkf Exp $ */ #include "tclInt.h" @@ -268,16 +268,12 @@ Tcl_SetByteArrayObj(objPtr, bytes, length) int length; /* Length of the array of bytes, which must * be >= 0. */ { - Tcl_ObjType *typePtr; ByteArray *byteArrayPtr; if (Tcl_IsShared(objPtr)) { Tcl_Panic("Tcl_SetByteArrayObj called with shared object"); } - typePtr = objPtr->typePtr; - if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { - (*typePtr->freeIntRepProc)(objPtr); - } + TclFreeIntRep(objPtr); Tcl_InvalidateStringRep(objPtr); byteArrayPtr = (ByteArray *) ckalloc(BYTEARRAY_SIZE(length)); @@ -397,15 +393,13 @@ SetByteArrayFromAny(interp, objPtr) Tcl_Interp *interp; /* Not used. */ Tcl_Obj *objPtr; /* The object to convert to type ByteArray. */ { - Tcl_ObjType *typePtr; int length; char *src, *srcEnd; unsigned char *dst; ByteArray *byteArrayPtr; Tcl_UniChar ch; - typePtr = objPtr->typePtr; - if (typePtr != &tclByteArrayType) { + if (objPtr->typePtr != &tclByteArrayType) { src = Tcl_GetStringFromObj(objPtr, &length); srcEnd = src + length; @@ -418,9 +412,7 @@ SetByteArrayFromAny(interp, objPtr) byteArrayPtr->used = dst - byteArrayPtr->bytes; byteArrayPtr->allocated = length; - if ((typePtr != NULL) && (typePtr->freeIntRepProc) != NULL) { - (*typePtr->freeIntRepProc)(objPtr); - } + TclFreeIntRep(objPtr); objPtr->typePtr = &tclByteArrayType; SET_BYTEARRAY(objPtr, byteArrayPtr); } |