|
From: Alexandre F. <ale...@gm...> - 2008-01-16 23:09:42
|
Hi again,
> Now, I could handle that case differently if I could find an unused
> field in Tcl_Obj's of NULL type (pure strings). Is there one ? Is the
> internalRep.twoPtrValue.ptr(1 or 2) usable for this purpose to denote
> the fact that a NULL-type object is mutable ?
In fact I have already spotted a suspicious point where the type is
set to NULL and the internalRep (in ptrAndLong form) is set to
{NULL,0} at the same time: it is in GetBignumFromObj:
if (objPtr->typePtr == &tclBignumType) {
if (copy || Tcl_IsShared(objPtr)) {
...
} else {
UNPACK_BIGNUM(objPtr, *bignumValue);
objPtr->internalRep.ptrAndLongRep.ptr = NULL;
objPtr->internalRep.ptrAndLongRep.value = 0;
objPtr->typePtr = NULL;
if (objPtr->bytes == NULL) {
TclInitStringRep(objPtr, tclEmptyStringRep, 0);
}
}
return TCL_OK;
Now I'm having a hard time understanding this: what if the string rep
is not NULL (for example if the bignum has just been printed) ? It
would seem that in this case, the object is reset to a pure string,
namely that representing the bignum. While if it was NULL (for example
just after a bignum computation), the string rep is empty. Why that
dichotomy ? And why touch the ptrAndLong ?
-Alex
|