diff options
author | dgp <dgp@users.sourceforge.net> | 2015-09-25 16:43:05 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2015-09-25 16:43:05 (GMT) |
commit | 41b3739aa61f95df2dfbaf0896100aaf73f2595a (patch) | |
tree | 0c7c8179288bb4a6cbabdcfd046defc5f8d1356a /generic/tclIO.c | |
parent | f9465250b939d54021e85ba03eaf63f31b4b3037 (diff) | |
parent | 2101ef45be45e0aa88d3e8c9725df9ca92309fe9 (diff) | |
download | tcl-41b3739aa61f95df2dfbaf0896100aaf73f2595a.zip tcl-41b3739aa61f95df2dfbaf0896100aaf73f2595a.tar.gz tcl-41b3739aa61f95df2dfbaf0896100aaf73f2595a.tar.bz2 |
Backout failed attempt to fix [32ae34e63a].
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 47 |
1 files changed, 4 insertions, 43 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index d154c77..8e9e346 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -102,30 +102,11 @@ typedef struct CopyState { Tcl_WideInt total; /* Total bytes transferred (written). */ Tcl_Interp *interp; /* Interp that started the copy. */ Tcl_Obj *cmdPtr; /* Command to be invoked at completion. */ - int refCount; /* Claim count on the struct */ - int bufInUse; /* Flag to govern access to buffer */ int bufSize; /* Size of appended buffer. */ char buffer[1]; /* Copy buffer, this must be the last * field. */ } CopyState; -static void -PreserveCopyState( - CopyState *csPtr) -{ - csPtr->refCount++; -} - -static void -ReleaseCopyState( - CopyState *csPtr) -{ - if (--csPtr->refCount) { - return; - } - ckfree(csPtr); -} - /* * All static variables used in this file are collected into a single instance * of the following structure. For multi-threaded implementations, there is @@ -9111,13 +9092,9 @@ TclCopyChannel( Tcl_IncrRefCount(cmdPtr); } csPtr->cmdPtr = cmdPtr; - csPtr->refCount = 1; - csPtr->bufInUse = 0; inStatePtr->csPtrR = csPtr; - PreserveCopyState(csPtr); outStatePtr->csPtrW = csPtr; - PreserveCopyState(csPtr); if (moveBytes) { return MoveBytes(csPtr); @@ -9403,11 +9380,6 @@ CopyData( /* Encoding control */ int underflow; /* Input underflow */ - if (csPtr->bufInUse) { - return TCL_OK; - } - PreserveCopyState(csPtr); - inChan = (Tcl_Channel) csPtr->readPtr; outChan = (Tcl_Channel) csPtr->writePtr; inStatePtr = csPtr->readPtr->state; @@ -9470,7 +9442,6 @@ CopyData( sizeb = (int) csPtr->toRead; } - csPtr->bufInUse = 1; if (inBinary || sameEncoding) { size = DoRead(inStatePtr->topChanPtr, csPtr->buffer, sizeb, !GotFlag(inStatePtr, CHANNEL_NONBLOCKING)); @@ -9526,7 +9497,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } } @@ -9547,7 +9517,6 @@ CopyData( } else { sizeb = WriteChars(outStatePtr->topChanPtr, buffer, sizeb); } - csPtr->bufInUse = 0; /* * [Bug 2895565]. At this point 'size' still contains the number of @@ -9619,7 +9588,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } @@ -9642,7 +9610,6 @@ CopyData( TclDecrRefCount(bufObj); bufObj = NULL; } - ReleaseCopyState(csPtr); return TCL_OK; } } /* while */ @@ -9658,7 +9625,7 @@ CopyData( */ total = csPtr->total; - if (cmdPtr && interp && csPtr->cmdPtr) { + if (cmdPtr && interp) { int code; /* @@ -9666,7 +9633,8 @@ CopyData( * arguments. Note that StopCopy frees our saved reference to the * original command obj. */ - cmdPtr = Tcl_DuplicateObj(csPtr->cmdPtr); + + cmdPtr = Tcl_DuplicateObj(cmdPtr); Tcl_IncrRefCount(cmdPtr); StopCopy(csPtr); Tcl_Preserve(interp); @@ -9694,7 +9662,6 @@ CopyData( } } } - ReleaseCopyState(csPtr); return result; } @@ -10012,16 +9979,10 @@ StopCopy( Tcl_DeleteChannelHandler(inChan, MBEvent, csPtr); Tcl_DeleteChannelHandler(outChan, MBEvent, csPtr); TclDecrRefCount(csPtr->cmdPtr); - csPtr->cmdPtr = NULL; } - if (inStatePtr->csPtrR == NULL) { - return; - } - ReleaseCopyState(inStatePtr->csPtrR); inStatePtr->csPtrR = NULL; - ReleaseCopyState(outStatePtr->csPtrW); outStatePtr->csPtrW = NULL; - ReleaseCopyState(csPtr); + ckfree(csPtr); } /* |