summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--generic/tclInt.h6
-rw-r--r--generic/tclListObj.c26
3 files changed, 14 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index 19d7e47..454bf32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-04-21 Don Porter <dgp@users.sourceforge.net>
+ * generic/tclInt.h: Use macro to set List intreps.
+ * generic/tclListObj.c:
+
* generic/tclCmdIL.c: Limits on list length were too strict.
* generic/tclInt.h: Revised panics to errors where possible.
* generic/tclListObj.c:
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 67aee93..fe06573 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2451,6 +2451,12 @@ typedef struct List {
#define ListRepPtr(listPtr) \
((List *) (listPtr)->internalRep.twoPtrValue.ptr1)
+#define ListSetIntRep(objPtr, listRepPtr) \
+ (objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(listRepPtr), \
+ (objPtr)->internalRep.twoPtrValue.ptr2 = NULL, \
+ (listRepPtr)->refCount++, \
+ (objPtr)->typePtr = &tclListType
+
#define ListObjGetElements(listPtr, objc, objv) \
((objv) = &(ListRepPtr(listPtr)->elements), \
(objc) = ListRepPtr(listPtr)->elemCount)
diff --git a/generic/tclListObj.c b/generic/tclListObj.c
index 4c40a8b..be3e212 100644
--- a/generic/tclListObj.c
+++ b/generic/tclListObj.c
@@ -234,11 +234,7 @@ Tcl_NewListObj(
*/
Tcl_InvalidateStringRep(listPtr);
- listPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
- listPtr->internalRep.twoPtrValue.ptr2 = NULL;
- listPtr->typePtr = &tclListType;
- listRepPtr->refCount++;
-
+ ListSetIntRep(listPtr, listRepPtr);
return listPtr;
}
#endif /* if TCL_MEM_DEBUG */
@@ -303,10 +299,7 @@ Tcl_DbNewListObj(
*/
Tcl_InvalidateStringRep(listPtr);
- listPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
- listPtr->internalRep.twoPtrValue.ptr2 = NULL;
- listPtr->typePtr = &tclListType;
- listRepPtr->refCount++;
+ ListSetIntRep(listPtr, listRepPtr);
return listPtr;
}
@@ -376,10 +369,7 @@ Tcl_SetListObj(
if (objc > 0) {
listRepPtr = NewListIntRep(objc, objv, 1);
- objPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
- objPtr->internalRep.twoPtrValue.ptr2 = NULL;
- objPtr->typePtr = &tclListType;
- listRepPtr->refCount++;
+ ListSetIntRep(objPtr, listRepPtr);
} else {
objPtr->bytes = tclEmptyStringRep;
objPtr->length = 0;
@@ -1700,10 +1690,7 @@ DupListInternalRep(
{
List *listRepPtr = ListRepPtr(srcPtr);
- listRepPtr->refCount++;
- copyPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
- copyPtr->internalRep.twoPtrValue.ptr2 = NULL;
- copyPtr->typePtr = &tclListType;
+ ListSetIntRep(copyPtr, listRepPtr);
}
/*
@@ -1878,11 +1865,8 @@ SetListFromAny(
*/
commitRepresentation:
- listRepPtr->refCount++;
TclFreeIntRep(objPtr);
- objPtr->internalRep.twoPtrValue.ptr1 = listRepPtr;
- objPtr->internalRep.twoPtrValue.ptr2 = NULL;
- objPtr->typePtr = &tclListType;
+ ListSetIntRep(objPtr, listRepPtr);
return TCL_OK;
}