/******************************************************************************* Copyright (c) 1997-2007, Perforce Software, Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *******************************************************************************/ /******************************************************************************* * Name : p4result.cc * * Author : Tony Smith <tony@perforce.com> or <tony@smee.org> * * Description : Ruby class for holding results of Perforce commands * ******************************************************************************/ #include <clientapi.h> #include "perlheaders.h" #include "p4perldebug.h" #include "p4result.h" P4Result::P4Result() { merged = 0; debug = 0; Init(); } void P4Result::Init() { output = newAV(); errors = newAV(); warnings = newAV(); } P4Result::~P4Result() { Clear(); } void P4Result::Clear() { sv_free((SV *) output); sv_free((SV *) warnings); sv_free((SV *) errors); } void P4Result::Reset(int merge) { if( P4PERL_DEBUG_FLOW ) printf( "[P4Result::Reset]: Discarding previous results\n" ); merged = merge; Clear(); Init(); } void P4Result::AddOutput( const char *msg ) { if( P4PERL_DEBUG_DATA ) printf( "[P4Result::AddOutput]: %s\n", msg ); av_push( output, newSVpv( msg, 0 ) ); } void P4Result::AddOutput( SV * out ) { if( P4PERL_DEBUG_DATA ) printf( "[P4Result::AddOutput]: (perl object)\n" ); av_push( output, out ); } void P4Result::AddError( Error *e ) { StrBuf m; e->Fmt( &m ); int s; s = e->GetSeverity(); // // Empty and informational messages are pushed out as output as nothing // worthy of error handling has occurred. Warnings go into the warnings // list and the rest are lumped together as errors. // if ( s == E_EMPTY || s == E_INFO ) { AddOutput( m.Text() ); return; } if( P4PERL_DEBUG_DATA ) printf( "[P4Result::AddError]: %s\n", m.Text() ); if ( s == E_WARN && !merged ) av_push( warnings, newSVpv( m.Text(), 0 ) ); else av_push( errors, newSVpv( m.Text(), 0 ) ); } I32 P4Result::OutputCount() { return av_len( output ) + 1; } I32 P4Result::ErrorCount() { return av_len( errors ) + 1; } I32 P4Result::WarningCount() { return av_len( warnings ) + 1; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 5869 | Tony Smith |
Fix memory leaks. Thanks to John LoVerso and Sandy Currier for tracking these down and sending me the patch. |
||
#5 | 5868 | Tony Smith |
Port P4Perl to Perl 5.8.8. This change is spectacularly ugly, but then so are the innards of Perl. See the long thread at: http://www.nntp.perl.org/group/perl.perl5.porters/2006/06/msg114383.html for details of the problem, and some discussion of solutions. I've had to come up with a solution that doesn't involve patching people's Perl installations, so my fix is even less easy on the eye but it appears to work, and hopefully hasn't broken things for older Perl versions. |
||
#4 | 5038 | Tony Smith |
Bug fix: Fix memory leaks in P4Perl reported by Craig Galley. Perl's reference count garbage collection is not much fun to work with, but hopefully this change plugs P4Perl's leaks. There's still a leak that remains, but whether it's in P4Perl's code or just in Perl I don't know. A loop like this: while( 1 ) { my $p4 = new P4; } will leak like a sieve but I'm pretty sure P4Perl is cleaning up as it should. While it's very difficult to be certain with Perl's memory mode, creating one P4 object and using it multiple times now appears to be pretty steady. Also fixed use of uninitialized debug variable which could produce debug output you hadn't asked for. |
||
#3 | 4864 | Tony Smith |
Bug fix: Introduce workaround for obscure 2000.1/2000.2 protocol bug that I really thought we'd seen the last of. Along the way, a total revamp of the debugging output - required to diagnose the problem. |
||
#2 | 4582 | Tony Smith |
Port new P4Perl architecture to Windows. Fixes a few porting issues and a couple of minor errors in the previous change. |
||
#1 | 4579 | Tony Smith |
Rewrite P4Perl to be more like P4Ruby. This change does away with the old P4/P4::Client split and pulls all the functionality of P4::Client into P4. Hence P4::Client is now deprecated. There are a few gotcha's - see the Changes file, and documentation for the details, but in general it's backwards compatible. As part of this change, I'm also releasing the previous current versions of P4 and P4::Client as released versions - for posterity. P4 now gets a v3.x version number so the old versions will stand out clearly. Hopefully it's all working - works fine for me - but people should consider this a beta build, for now at least. |