summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-27 15:05:28 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-12-27 15:05:28 (GMT)
commitb5100ee98faeec86fab0f3a532f448e0565cf41d (patch)
tree50404fb0a39698c9462bd2ceee8c74c909f28a20 /generic
parent2951fec86bc93ecddf4fd9cdb697df49992879cc (diff)
parentd12ee9da30592f7dd3121c17b48056fff83824dc (diff)
downloadtcl-b5100ee98faeec86fab0f3a532f448e0565cf41d.zip
tcl-b5100ee98faeec86fab0f3a532f448e0565cf41d.tar.gz
tcl-b5100ee98faeec86fab0f3a532f448e0565cf41d.tar.bz2
merge trunk
Diffstat (limited to 'generic')
-rw-r--r--generic/tclListObj.c9
-rw-r--r--generic/tclUtil.c18
2 files changed, 15 insertions, 12 deletions
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 3668b45..53c3f66 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -909,6 +909,10 @@ Tcl_ListObjReplace(
isShared = (listRepPtr->refCount > 1);
numRequired = numElems - count + objc;
+ for (i = 0; i < objc; i++) {
+ Tcl_IncrRefCount(objv[i]);
+ }
+
if ((numRequired <= listRepPtr->maxElemCount) && !isShared) {
int shift;
@@ -1027,14 +1031,11 @@ Tcl_ListObjReplace(
}
/*
- * Insert the new elements into elemPtrs before "first". We don't do a
- * memcpy here because we must increment the reference counts for the
- * added elements, so we must explicitly loop anyway.
+ * Insert the new elements into elemPtrs before "first".
*/
for (i=0,j=first ; i<objc ; i++,j++) {
elemPtrs[j] = objv[i];
- Tcl_IncrRefCount(objv[i]);
}
/*
diff --git a/generic/tclUtil.c b/generic/tclUtil.c
index 4b69628..c8f73da 100644
--- a/generic/tclUtil.c
+++ b/generic/tclUtil.c
@@ -2827,14 +2827,16 @@ TclDStringToObj(
{
Tcl_Obj *result;
- if (dsPtr->length == 0) {
- TclNewObj(result);
- } else if (dsPtr->string == dsPtr->staticSpace) {
- /*
- * Static buffer, so must copy.
- */
-
- TclNewStringObj(result, dsPtr->string, dsPtr->length);
+ if (dsPtr->string == dsPtr->staticSpace) {
+ if (dsPtr->length == 0) {
+ TclNewObj(result);
+ } else {
+ /*
+ * Static buffer, so must copy.
+ */
+
+ TclNewStringObj(result, dsPtr->string, dsPtr->length);
+ }
} else {
/*
* Dynamic buffer, so transfer ownership and reset.