summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorhobbs <hobbs>2001-08-07 01:00:02 (GMT)
committerhobbs <hobbs>2001-08-07 01:00:02 (GMT)
commit84d9840ea49d4c8c3a29d12615b526c25878518d (patch)
tree0cea4199bb36de1d133cfff2f537226a7b1d748a /generic
parentf546af5ac7018d30c4776d9c66006e2e8e425de7 (diff)
downloadtcl-84d9840ea49d4c8c3a29d12615b526c25878518d.zip
tcl-84d9840ea49d4c8c3a29d12615b526c25878518d.tar.gz
tcl-84d9840ea49d4c8c3a29d12615b526c25878518d.tar.bz2
* generic/tclFileName.c (Tcl_FSSplitPath): update to Tcl style
guide. * generic/tclFCmd.c (FileCopyRename): fixed mem leak in introduction of vfs code where a new Tcl_Obj wasn't freed.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclFCmd.c42
-rw-r--r--generic/tclFileName.c25
2 files changed, 33 insertions, 34 deletions
diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c
index c169427..e0eccf9 100644
--- a/generic/tclFCmd.c
+++ b/generic/tclFCmd.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFCmd.c,v 1.7 2001/07/31 19:12:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tclFCmd.c,v 1.8 2001/08/07 01:00:02 hobbs Exp $
*/
#include "tclInt.h"
@@ -188,11 +188,12 @@ FileCopyRename(interp, objc, objv, copyFlag)
temp = Tcl_NewListObj(2, jargv);
newFileName = Tcl_FSJoinPath(temp, -1);
Tcl_IncrRefCount(newFileName);
- Tcl_DecrRefCount(temp);
-
result = CopyRenameOneFile(interp, objv[i], newFileName, copyFlag,
force);
Tcl_DecrRefCount(newFileName);
+ Tcl_DecrRefCount(temp);
+ Tcl_DecrRefCount(source);
+
if (result == TCL_ERROR) {
break;
}
@@ -756,20 +757,18 @@ FileBasename(interp, pathPtr)
Tcl_Obj *pathPtr; /* Path whose basename to extract. */
{
int objc;
- Tcl_Obj *split;
- Tcl_Obj *resPtr = NULL;
+ Tcl_Obj *splitPtr;
+ Tcl_Obj *resultPtr = NULL;
- split = Tcl_FSSplitPath(pathPtr, &objc);
+ splitPtr = Tcl_FSSplitPath(pathPtr, &objc);
if (objc != 0) {
if ((objc == 1) && (*Tcl_GetString(pathPtr) == '~')) {
-
+ Tcl_DecrRefCount(splitPtr);
if (Tcl_FSConvertToPathType(interp, pathPtr) != TCL_OK) {
- Tcl_DecrRefCount(split);
return NULL;
}
- Tcl_DecrRefCount(split);
- split = Tcl_FSSplitPath(pathPtr, &objc);
+ splitPtr = Tcl_FSSplitPath(pathPtr, &objc);
}
/*
@@ -778,23 +777,20 @@ FileBasename(interp, pathPtr)
*/
if (objc > 0) {
- if (objc > 1) {
- Tcl_ListObjIndex(NULL, split, objc-1, &resPtr);
- } else {
- Tcl_Obj *temp;
- Tcl_ListObjIndex(NULL, split, 0, &temp);
- if (Tcl_GetPathType(Tcl_GetString(temp)) == TCL_PATH_RELATIVE) {
- Tcl_ListObjIndex(NULL, split, objc-1, &resPtr);
- }
+ Tcl_ListObjIndex(NULL, splitPtr, objc-1, &resultPtr);
+ if ((objc == 1) &&
+ (Tcl_GetPathType(Tcl_GetString(resultPtr))
+ != TCL_PATH_RELATIVE)) {
+ resultPtr = NULL;
}
}
}
- if (resPtr == NULL) {
- resPtr = Tcl_NewStringObj("",0);
+ if (resultPtr == NULL) {
+ resultPtr = Tcl_NewObj();
}
- Tcl_IncrRefCount(resPtr);
- Tcl_DecrRefCount(split);
- return resPtr;
+ Tcl_IncrRefCount(resultPtr);
+ Tcl_DecrRefCount(splitPtr);
+ return resultPtr;
}
/*
diff --git a/generic/tclFileName.c b/generic/tclFileName.c
index 31332ac..0da7299 100644
--- a/generic/tclFileName.c
+++ b/generic/tclFileName.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclFileName.c,v 1.15 2001/07/31 19:12:06 vincentdarley Exp $
+ * RCS: @(#) $Id: tclFileName.c,v 1.16 2001/08/07 01:00:02 hobbs Exp $
*/
#include "tclInt.h"
@@ -331,21 +331,24 @@ Tcl_GetPathType(path)
*/
Tcl_Obj*
-Tcl_FSSplitPath(Tcl_Obj* pathPtr, int *lenPtr) {
+Tcl_FSSplitPath(pathPtr, lenPtr)
+ Tcl_Obj *pathPtr; /* Path to split. */
+ int *lenPtr; /* int to store number of path elements. */
+{
int argc, i;
- char** argv;
- Tcl_Obj* res;
-
- Tcl_SplitPath(Tcl_GetString(pathPtr),&argc,&argv);
+ char **argv;
+ Tcl_Obj *resultPtr = Tcl_NewObj();
+
+ Tcl_SplitPath(Tcl_GetString(pathPtr), &argc, &argv);
if (lenPtr != NULL) {
*lenPtr = argc;
}
- res = Tcl_NewListObj(0,NULL);
- for (i=0;i<argc;i++) {
- Tcl_ListObjAppendElement(NULL, res, Tcl_NewStringObj(argv[i],-1));
+ for (i = 0; i < argc; i++) {
+ Tcl_ListObjAppendElement(NULL, resultPtr,
+ Tcl_NewStringObj(argv[i], -1));
}
- ckfree((char*)argv);
- return res;
+ ckfree((char *) argv);
+ return resultPtr;
}
/*