Changes in external/tcl/tclStringObj.c [adeddd8:d7d2da3] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/tcl/tclStringObj.c
radeddd8 rd7d2da3 50 50 * Tcl_NewStringObj -- 51 51 * 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. 54 58 * 55 59 * Results: … … 66 70 *---------------------------------------------------------------------- 67 71 */ 72 73 #ifdef TCL_MEM_DEBUG 74 #undef Tcl_NewStringObj 68 75 69 76 Tcl_Obj * … … 76 83 * NULL byte. */ 77 84 { 85 return Tcl_DbNewStringObj(bytes, length, "unknown", 0); 86 } 87 88 #else /* if not TCL_MEM_DEBUG */ 89 90 Tcl_Obj * 91 Tcl_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 { 78 99 register Tcl_Obj *objPtr; 79 100 … … 85 106 return objPtr; 86 107 } 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 143 Tcl_Obj * 144 Tcl_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 168 Tcl_Obj * 169 Tcl_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 */ 87 184 88 185
Note:
See TracChangeset
for help on using the changeset viewer.