diff options
| author | donal.k.fellows@manchester.ac.uk <dkf> | 2004-09-29 22:17:28 (GMT) |
|---|---|---|
| committer | donal.k.fellows@manchester.ac.uk <dkf> | 2004-09-29 22:17:28 (GMT) |
| commit | 6cd42534eb8e9ab72ca598391f20a89ee91256c7 (patch) | |
| tree | 9a574faca8ab395bddcb8ebbfcba24f070a7296a /generic/tclBinary.c | |
| parent | 5168f3edd958f497f7c6d23b5d6e0ddf377bf31f (diff) | |
| download | tcl-6cd42534eb8e9ab72ca598391f20a89ee91256c7.zip tcl-6cd42534eb8e9ab72ca598391f20a89ee91256c7.tar.gz tcl-6cd42534eb8e9ab72ca598391f20a89ee91256c7.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); } |
