diff options
author | dgp <dgp@users.sourceforge.net> | 2009-02-10 17:37:35 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2009-02-10 17:37:35 (GMT) |
commit | 0de29ee94bd90a5b0401dd31599c0c5a44c387e2 (patch) | |
tree | 833212d6baee4dbeccaa67d27edb81e289350c76 | |
parent | d1aef8650a1ebf59f57b1c605264aadcc928fa57 (diff) | |
download | tcl-0de29ee94bd90a5b0401dd31599c0c5a44c387e2.zip tcl-0de29ee94bd90a5b0401dd31599c0c5a44c387e2.tar.gz tcl-0de29ee94bd90a5b0401dd31599c0c5a44c387e2.tar.bz2 |
Simplify Tcl_SetObjLength by removing unreachable code.
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | generic/tclStringObj.c | 13 |
2 files changed, 4 insertions, 10 deletions
@@ -8,6 +8,7 @@ Convert all Tcl_InvalidateStringRep() calls into macros. Simplify Tcl_AttemptSetObjLength by removing unreachable code. Simplify SetStringFromAny() by removing unreachable and duplicate code. + Simplify Tcl_SetObjLength by removing unreachable code. 2009-02-09 Jan Nijtmans <nijtmans@users.sf.net> diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index 15ed7af..940e6d1 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.92 2009/02/10 17:28:37 dgp Exp $ */ + * RCS: @(#) $Id: tclStringObj.c,v 1.93 2009/02/10 17:37:35 dgp Exp $ */ #include "tclInt.h" #include "tommath.h" @@ -807,16 +807,9 @@ Tcl_SetObjLength( */ if (objPtr->bytes != tclEmptyStringRep) { - objPtr->bytes = ckrealloc((char *) objPtr->bytes, - (unsigned) (length + 1)); + objPtr->bytes = ckrealloc(objPtr->bytes, (unsigned) length+1); } else { - char *newBytes = ckalloc((unsigned) (length+1)); - - if (objPtr->bytes != NULL && objPtr->length != 0) { - memcpy(newBytes, objPtr->bytes, (size_t) objPtr->length); - TclInvalidateStringRep(objPtr); - } - objPtr->bytes = newBytes; + objPtr->bytes = ckalloc((unsigned) length+1); } stringPtr->allocated = length; |