Author: Ashok P. Nadkarni <[email protected]>
State: Final
Type: Project
Vote: Done
Tcl-Version: 8.7
Vote-Summary: Accepted 10/0/0
Votes-For: AK, AN, BG, DP, HO, JN, KW, MC, RA, SL
Votes-Against: none
Votes-Present: none
Abstract
This TIP proposes addition of a new field to the internal Tcl_Obj
representation to hold a pointer and Tcl_Size value.
Rationale
Custom Tcl_Obj internal representation often require a pointer and length
internal representation. In Tcl 8, the Tcl_Obj.internalRep.ptrAndLongRep field
targeted this use case. With Tcl 9, where supported lengths on 64-bit platforms
are greater than ULONG_MAX on Windows, this no longer suffices for the purpose.
Hijacking the twoPtrValue field involves casts, not a good practice. The
alternative of a separate allocation is an unnecessary performance loss.
Specification
The following new field will be added to the Tcl_ObjIntenalRep union
that holds Tcl_Obj internal representation.
struct {
void *ptr;
Tcl_Size size;
} ptrAndSize;
The size of the Tcl_Obj structure does not change with this addition
due to the already existing twoPtrValue field.
Discussion
The integer field in the ptrAndSize is explicitly chosen to be Tcl_Size
and not Tcl_WideInt, ptrdiff_t and size_t so as to not change the
size of Tcl_Obj on Windows platforms.
Implementation
See the tip-707 branch.
Copyright
This document has been placed in the public domain.
