summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--generic/tclStringObj.c13
2 files changed, 4 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index cf6e42d..c05dd16 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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;