|
2026-01-14
| ||
| 14:56 | • Ticket [07000bd237] Bignum documentation needs to be clarified w.r.t mp_int hand... artifact: 47dcfd7e07 user: apnadkarni | |
|
2026-01-12
| ||
| 03:39 | • Ticket [07000bd237]: 3 changes artifact: 0bdfdcd1f0 user: cdubois | |
|
2025-11-10
| ||
| 16:57 | • New ticket [07000bd237]. artifact: 3f2cb31e6c user: apnadkarni | |
Bignum documentation needs to be clarified w.r.t mp_int handling
Open07000bd237c021d5bf7bcc721a6ab3570ecc4f08Created 1 year agoUpdated 322 days ago
Descriptionmarkdown2025-11-10 16:57:22
The documentation for Tcl_{Set,Get,Take}BigNum needs to clarified with respect to handling of mp_int memory. At least,
Tcl_SetBignumObj should clarify that the passed
mp_intis cleared by Tcl and will not hold it original valueTcl_{Get,Take}BignumFromObj -
mp_clearneeds to be called on the returnedmp_intvalues to free memory.
cduboisplain2026-01-12 03:39:06
Thanks for flagging this. Making the ownership/lifetime contract for mp_int explicit is important to prevent leaks and accidental misuse. I agree the docs should be strict here. I will cross-check the current implementation (including Tcl_TakeBignumFromObj behaviour for shared vs unshared objects) and then propose a documentation patch. Proposed doc clarifications (subject to confirming the implementation): - Tcl_SetBignumObj: clarify whether the function clears/consumes the supplied mp_int (i.e., callers must treat it as cleared and not rely on its prior value after the call). - Tcl_GetBignumFromObj / Tcl_TakeBignumFromObj: clarify whether the caller must call mp_clear on the mp_int they receive/populate to release internal allocations, and what postconditions apply to the source object in the Take case. I can also add a minimal code snippet illustrating the correct cleanup pattern.
apnadkarniplain2026-01-14 14:56:51
@cdubois, Great, a documentation patch would be greatly appreciated. It is really quite confusing as it stands.
Log in (anonymous is fine) to add a comment.