Fork me on GitHub

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • external/tcl/tclStringObj.c

    radeddd8 rd7d2da3  
    5050 * Tcl_NewStringObj --
    5151 *
    52  *      This procedure creates a new string object and initializes it from
    53  *      the byte pointer and length arguments.
     52 *      This procedure is normally called when not debugging: i.e., when
     53 *      TCL_MEM_DEBUG is not defined. It creates a new string object and
     54 *      initializes it from the byte pointer and length arguments.
     55 *
     56 *      When TCL_MEM_DEBUG is defined, this procedure just returns the
     57 *      result of calling the debugging version Tcl_DbNewStringObj.
    5458 *
    5559 * Results:
     
    6670 *----------------------------------------------------------------------
    6771 */
     72
     73#ifdef TCL_MEM_DEBUG
     74#undef Tcl_NewStringObj
    6875
    6976Tcl_Obj *
     
    7683                                 * NULL byte. */
    7784{
     85    return Tcl_DbNewStringObj(bytes, length, "unknown", 0);
     86}
     87
     88#else /* if not TCL_MEM_DEBUG */
     89
     90Tcl_Obj *
     91Tcl_NewStringObj(bytes, length)
     92    register char *bytes;       /* Points to the first of the length bytes
     93                                 * used to initialize the new object. */
     94    register int length;        /* The number of bytes to copy from "bytes"
     95                                 * when initializing the new object. If
     96                                 * negative, use bytes up to the first
     97                                 * NULL byte. */
     98{
    7899    register Tcl_Obj *objPtr;
    79100
     
    85106    return objPtr;
    86107}
     108#endif /* TCL_MEM_DEBUG */
     109
     110
     111/*
     112 *----------------------------------------------------------------------
     113 *
     114 * Tcl_DbNewStringObj --
     115 *
     116 *      This procedure is normally called when debugging: i.e., when
     117 *      TCL_MEM_DEBUG is defined. It creates new string objects. It is the
     118 *      same as the Tcl_NewStringObj procedure above except that it calls
     119 *      Tcl_DbCkalloc directly with the file name and line number from its
     120 *      caller. This simplifies debugging since then the checkmem command
     121 *      will report the correct file name and line number when reporting
     122 *      objects that haven't been freed.
     123 *
     124 *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
     125 *      result of calling Tcl_NewStringObj.
     126 *
     127 * Results:
     128 *      A newly created string object is returned that has ref count zero.
     129 *
     130 * Side effects:
     131 *      The new object's internal string representation will be set to a
     132 *      copy of the length bytes starting at "bytes". If "length" is
     133 *      negative, use bytes up to the first NULL byte; i.e., assume "bytes"
     134 *      points to a C-style NULL-terminated string. The object's type is set
     135 *      to NULL. An extra NULL is added to the end of the new object's byte
     136 *      array.
     137 *
     138 *----------------------------------------------------------------------
     139 */
     140
     141#ifdef TCL_MEM_DEBUG
     142
     143Tcl_Obj *
     144Tcl_DbNewStringObj(bytes, length, file, line)
     145    register char *bytes;       /* Points to the first of the length bytes
     146                                 * used to initialize the new object. */
     147    register int length;        /* The number of bytes to copy from "bytes"
     148                                 * when initializing the new object. If
     149                                 * negative, use bytes up to the first
     150                                 * NULL byte. */
     151    char *file;                 /* The name of the source file calling this
     152                                 * procedure; used for debugging. */
     153    int line;                   /* Line number in the source file; used
     154                                 * for debugging. */
     155{
     156    register Tcl_Obj *objPtr;
     157
     158    if (length < 0) {
     159        length = (bytes? strlen(bytes) : 0);
     160    }
     161    TclDbNewObj(objPtr, file, line);
     162    TclInitStringRep(objPtr, bytes, length);
     163    return objPtr;
     164}
     165
     166#else /* if not TCL_MEM_DEBUG */
     167
     168Tcl_Obj *
     169Tcl_DbNewStringObj(bytes, length, file, line)
     170    register char *bytes;       /* Points to the first of the length bytes
     171                                 * used to initialize the new object. */
     172    register int length;        /* The number of bytes to copy from "bytes"
     173                                 * when initializing the new object. If
     174                                 * negative, use bytes up to the first
     175                                 * NULL byte. */
     176    char *file;                 /* The name of the source file calling this
     177                                 * procedure; used for debugging. */
     178    int line;                   /* Line number in the source file; used
     179                                 * for debugging. */
     180{
     181    return Tcl_NewStringObj(bytes, length);
     182}
     183#endif /* TCL_MEM_DEBUG */
    87184
    88185
Note: See TracChangeset for help on using the changeset viewer.