Changes in external/tcl/tclListObj.c [d7d2da3:adeddd8] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/tcl/tclListObj.c
rd7d2da3 radeddd8 46 46 * Tcl_NewListObj -- 47 47 * 48 * This procedure is normally called when not debugging: i.e., when 49 * TCL_MEM_DEBUG is not defined. It creates a new list object from an 50 * (objc,objv) array: that is, each of the objc elements of the array 51 * referenced by objv is inserted as an element into a new Tcl object. 52 * 53 * When TCL_MEM_DEBUG is defined, this procedure just returns the 54 * result of calling the debugging version Tcl_DbNewListObj. 48 * This procedure creates a new list object from an (objc,objv) array: 49 * that is, each of the objc elements of the array referenced by objv 50 * is inserted as an element into a new Tcl object. 55 51 * 56 52 * Results: … … 66 62 *---------------------------------------------------------------------- 67 63 */ 68 69 #ifdef TCL_MEM_DEBUG70 #undef Tcl_NewListObj71 72 Tcl_Obj *73 Tcl_NewListObj(objc, objv)74 int objc; /* Count of objects referenced by objv. */75 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */76 {77 return Tcl_DbNewListObj(objc, objv, "unknown", 0);78 }79 80 #else /* if not TCL_MEM_DEBUG */81 64 82 65 Tcl_Obj * … … 112 95 return listPtr; 113 96 } 114 #endif /* if TCL_MEM_DEBUG */115 116 117 /*118 *----------------------------------------------------------------------119 *120 * Tcl_DbNewListObj --121 *122 * This procedure is normally called when debugging: i.e., when123 * TCL_MEM_DEBUG is defined. It creates new list objects. It is the124 * same as the Tcl_NewListObj procedure above except that it calls125 * Tcl_DbCkalloc directly with the file name and line number from its126 * caller. This simplifies debugging since then the checkmem command127 * will report the correct file name and line number when reporting128 * objects that haven't been freed.129 *130 * When TCL_MEM_DEBUG is not defined, this procedure just returns the131 * result of calling Tcl_NewListObj.132 *133 * Results:134 * A new list object is returned that is initialized from the object135 * pointers in objv. If objc is less than or equal to zero, an empty136 * object is returned. The new object's string representation137 * is left NULL. The new list object has ref count 0.138 *139 * Side effects:140 * The ref counts of the elements in objv are incremented since the141 * resulting list now refers to them.142 *143 *----------------------------------------------------------------------144 */145 146 #ifdef TCL_MEM_DEBUG147 148 Tcl_Obj *149 Tcl_DbNewListObj(objc, objv, file, line)150 int objc; /* Count of objects referenced by objv. */151 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */152 char *file; /* The name of the source file calling this153 * procedure; used for debugging. */154 int line; /* Line number in the source file; used155 * for debugging. */156 {157 register Tcl_Obj *listPtr;158 register Tcl_Obj **elemPtrs;159 register List *listRepPtr;160 int i;161 162 TclDbNewObj(listPtr, file, line);163 164 if (objc > 0) {165 Tcl_InvalidateStringRep(listPtr);166 167 elemPtrs = (Tcl_Obj **)168 ckalloc((unsigned) (objc * sizeof(Tcl_Obj *)));169 for (i = 0; i < objc; i++) {170 elemPtrs[i] = objv[i];171 Tcl_IncrRefCount(elemPtrs[i]);172 }173 174 listRepPtr = (List *) ckalloc(sizeof(List));175 listRepPtr->maxElemCount = objc;176 listRepPtr->elemCount = objc;177 listRepPtr->elements = elemPtrs;178 179 listPtr->internalRep.otherValuePtr = (VOID *) listRepPtr;180 listPtr->typePtr = &tclListType;181 }182 return listPtr;183 }184 185 #else /* if not TCL_MEM_DEBUG */186 187 Tcl_Obj *188 Tcl_DbNewListObj(objc, objv, file, line)189 int objc; /* Count of objects referenced by objv. */190 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */191 char *file; /* The name of the source file calling this192 * procedure; used for debugging. */193 int line; /* Line number in the source file; used194 * for debugging. */195 {196 return Tcl_NewListObj(objc, objv);197 }198 #endif /* TCL_MEM_DEBUG */199 97 200 98
Note:
See TracChangeset
for help on using the changeset viewer.