Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 0bdfdcd1f00e395e5dddc0b5c47005854840a3a27d80e03dddc814a8154fba58
Ticket: 07000bd237c021d5bf7bcc721a6ab3570ecc4f08
Bignum documentation needs to be clarified w.r.t mp_int handling
User & Date: cdubois on 2026-01-12 03:39:06
Changes

  1. icomment:
    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.
    
  2. login: "cdubois"
  3. mimetype: "text/plain"