Skip to content
Tcl Source Code History Of Ticket 756883ffffffffff
Login

History Of Ticket 756883ffffffffff

Artifacts Associated With Ticket 756883ffffffffff

  1. Ticket change [c2aa33b136] (rid 111522) by ysutjandra on 2003-06-18 22:24:41:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Hi,
      
      In tclResult.c  inside function ResetObjResult(iPtr)
      
      Would you consider
      
      instead of...
          if (Tcl_IsShared(objResultPtr)) {
             ...
          } else {
              if ((objResultPtr->bytes != NULL)
                      && (objResultPtr->bytes != 
      tclEmptyStringRep)) {
                  ckfree((char *) objResultPtr->bytes);
              }
              objResultPtr->bytes  = tclEmptyStringRep;
              objResultPtr->length = 0;
              if ((objResultPtr->typePtr != NULL)
                      && (objResultPtr->typePtr->freeIntRepProc !
      = NULL)) {
                  objResultPtr->typePtr->freeIntRepProc
      (objResultPtr);
              }
              objResultPtr->typePtr = (Tcl_ObjType *) NULL;
          }
      
      
      consider...
          if (Tcl_IsShared(objResultPtr)) {
             ...
          } else {
              TclDecrRefCount(objResultPtr);
                /* This automatically
                   calls the free function if result object
                   holds its own internal representation.
                   And depending on the free function of the 
      registered type
                   It might already invalidate the 'bytes' field of 
      the Tcl_Obj
                   and set the 'bytes' to NULL and 
                   the 'length' to zero.
                */
              if ((objResultPtr->bytes != NULL)
                      && (objResultPtr->bytes != 
      tclEmptyStringRep)) {
                  ckfree((char *) objResultPtr->bytes);
              }
              objResultPtr->bytes  = tclEmptyStringRep;
              objResultPtr->length = 0;
              objResultPtr->typePtr = (Tcl_ObjType *) NULL;
              Tcl_IncrRefCount(objResultPtr);
          }
      
      
      I'm not sure if it's a bug, but with the current 
      implementation, the registered free function is called 
      when refCount is still one.
      
      Moreover, if the result object holds its internal 
      representation, the bytes field may hold ths string that 
      is obtained from calling Tcl_UpdateStringObj, which calls 
      the registered UpdateStringProc.
      
      The software client is free to use its own memory 
      allocator when updating the bytes string.  So I think it's 
      a bug to assume that the bytes is allocated using 
      ckalloc.
      
      -- Yohan
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "ysutjandra"
    9. subsystem initialized to: "10. Objects"
    10. title initialized to:
      ResetObjResult to call registered free function first time
      
    11. type initialized to: "RFE"
  2. Ticket change [d1d55acf1c] (rid 113422) by jenglish on 2003-09-06 08:58:53:

    1. icomment:
      Logged In: YES 
      user_id=68433
      
      > The software client is free to use its own memory 
      allocator 
      > when updating the bytes string
      
      This is incorrect: according to Tcl_RegisterObjType(3), the
      'updateStringProc' method *must* use Tcl_Alloc or ckalloc to
      allocate storage for the byte array.
      
      
    2. login: "jenglish"
    3. mimetype: "text/plain"
    4. username: "jenglish"
  3. Ticket change [c584e21b7e] (rid 112014) by ysutjandra on 2003-09-09 00:17:52:

    1. icomment:
      Logged In: YES 
      user_id=799156
      
      You're right... we use Tcl_Alloc to allocate space for string 
      bytes.
      
      But still please consider using Tcl_DecrRefCount and 
      Tcl_IncrRefCount instead of calling the free function directly.
      
      The reason is that my program flags an error if the free 
      function is called when refCount is still greater than zero.  
      This flag is useful because a specific object type that we 
      implement will not be able to be recreated once it is deleted.  
      So the flag is to notify users that the current object held by 
      a tcl variable has been freed and they should recreate the 
      object themselves.
      
      -- Yohan
      
      
    2. login: "ysutjandra"
    3. mimetype: "text/plain"
    4. username: "ysutjandra"
  4. Ticket change [538e4901e0] (rid 93778) by msofer on 2005-11-26 17:49:54:

    1. closedate changed to: "2005-11-26T10:49:54"
    2. closer changed to: "msofer"
    3. icomment:
      Logged In: YES 
      user_id=148712
      
      The freeProc for any Tcl_Obj type may be called with any
      value of refCount - it will happen if the Tcl_Obj shimmers.
      A Tcl_Obj's internal rep must be able to be reconstructed
      from the string representation, by design. 
      
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Rejected"
    7. status changed to: "Closed"
    8. username: "msofer"