diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-06-25 09:23:23 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-06-25 09:23:23 (GMT) |
commit | 6de91b6b7d469c5f8d511700b75689df23e43fd1 (patch) | |
tree | 90f2e6301f5b1f1d4ece4510cdfe8b9dadcf074d /generic/tclIOUtil.c | |
parent | 4eb006ef70aa3737a687697eb03ba83b080e1a1a (diff) | |
parent | 076eb7c9e473f60d3821b1fcc622f69fbb8eba14 (diff) | |
download | tcl-6de91b6b7d469c5f8d511700b75689df23e43fd1.zip tcl-6de91b6b7d469c5f8d511700b75689df23e43fd1.tar.gz tcl-6de91b6b7d469c5f8d511700b75689df23e43fd1.tar.bz2 |
merge trunk
Diffstat (limited to 'generic/tclIOUtil.c')
-rw-r--r-- | generic/tclIOUtil.c | 49 |
1 files changed, 17 insertions, 32 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index f466ca8..b8bb0f7 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -163,7 +163,6 @@ const Tcl_Filesystem tclNativeFilesystem = { static FilesystemRecord nativeFilesystemRecord = { NULL, &tclNativeFilesystem, - 1, NULL, NULL }; @@ -419,9 +418,8 @@ FsThrExitProc( fsRecPtr = tsdPtr->filesystemList; while (fsRecPtr != NULL) { tmpFsRecPtr = fsRecPtr->nextPtr; - if (--fsRecPtr->fileRefCount <= 0) { - ckfree(fsRecPtr); - } + fsRecPtr->fsPtr = NULL; + ckfree(fsRecPtr); fsRecPtr = tmpFsRecPtr; } tsdPtr->initialized = 0; @@ -528,7 +526,7 @@ static void FsRecacheFilesystemList(void) { ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&tclFsDataKey); - FilesystemRecord *fsRecPtr, *tmpFsRecPtr = NULL; + FilesystemRecord *fsRecPtr, *tmpFsRecPtr = NULL, *toFree = NULL; /* * Trash the current cache. @@ -537,9 +535,9 @@ FsRecacheFilesystemList(void) fsRecPtr = tsdPtr->filesystemList; while (fsRecPtr != NULL) { tmpFsRecPtr = fsRecPtr->nextPtr; - if (--fsRecPtr->fileRefCount <= 0) { - ckfree(fsRecPtr); - } + fsRecPtr->fsPtr = NULL; + fsRecPtr->nextPtr = toFree; + toFree = fsRecPtr; fsRecPtr = tmpFsRecPtr; } tsdPtr->filesystemList = NULL; @@ -574,6 +572,12 @@ FsRecacheFilesystemList(void) fsRecPtr = fsRecPtr->prevPtr; } + while (toFree) { + FilesystemRecord *next = toFree->nextPtr; + ckfree(toFree); + toFree = next; + } + /* * Make sure the above gets released on thread exit. */ @@ -730,14 +734,10 @@ TclFinalizeFilesystem(void) while (fsRecPtr != NULL) { FilesystemRecord *tmpFsRecPtr = fsRecPtr->nextPtr; - if (fsRecPtr->fileRefCount <= 0) { - /* - * The native filesystem is static, so we don't free it. - */ + /* The native filesystem is static, so we don't free it. */ - if (fsRecPtr->fsPtr != &tclNativeFilesystem) { - ckfree(fsRecPtr); - } + if (fsRecPtr != &nativeFilesystemRecord) { + ckfree(fsRecPtr); } fsRecPtr = tmpFsRecPtr; } @@ -774,11 +774,6 @@ TclResetFilesystem(void) { filesystemList = &nativeFilesystemRecord; - /* - * Note, at this point, I believe nativeFilesystemRecord -> fileRefCount - * should equal 1 and if not, we should try to track down the cause. - */ - #ifdef __WIN32__ /* * Cleans up the win32 API filesystem proc lookup table. This must happen @@ -836,13 +831,6 @@ Tcl_FSRegister( newFilesystemPtr->fsPtr = fsPtr; /* - * We start with a refCount of 1. If this drops to zero, then anyone is - * welcome to ckfree us. - */ - - newFilesystemPtr->fileRefCount = 1; - - /* * Is this lock and wait strictly speaking necessary? Since any iterators * out there will have grabbed a copy of the head of the list and be * iterating away from that, if we add a new element to the head of the @@ -915,7 +903,7 @@ Tcl_FSUnregister( */ fsRecPtr = filesystemList; - while ((retVal == TCL_ERROR) && (fsRecPtr->fsPtr != &tclNativeFilesystem)) { + while ((retVal == TCL_ERROR) && (fsRecPtr != &nativeFilesystemRecord)) { if (fsRecPtr->fsPtr == fsPtr) { if (fsRecPtr->prevPtr) { fsRecPtr->prevPtr->nextPtr = fsRecPtr->nextPtr; @@ -936,10 +924,7 @@ Tcl_FSUnregister( theFilesystemEpoch++; - fsRecPtr->fileRefCount--; - if (fsRecPtr->fileRefCount <= 0) { - ckfree(fsRecPtr); - } + ckfree(fsRecPtr); retVal = TCL_OK; } else { |