[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/protocols/messenger/libpapillon
From: Michaƫl Larouche <larouche () kde ! org>
Date: 2007-01-03 18:00:18
Message-ID: 1167847218.502335.13594.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 619560 by mlarouche:
Use Qt4 QByteArray instead of memcpy().
M +6 -10 http/httpcoreprotocol.cpp
M +7 -12 messengercoreprotocol.cpp
--- trunk/KDE/kdenetwork/kopete/protocols/messenger/libpapillon/http/httpcoreprotocol.cpp #619559:619560
@@ -63,10 +63,8 @@
void HttpCoreProtocol::addIncomingData(const QByteArray &incomingBytes )
{
- // store locally
- int oldsize = d->in.size();
- d->in.resize( oldsize + incomingBytes.size() );
- memcpy( d->in.data() + oldsize, incomingBytes.data(), incomingBytes.size() );
+ // Append incoming bytes to incoming buffer
+ d->in += incomingBytes;
// convert every event in the chunk to a Transfer, signalling it back to the clientstream
int parsedBytes = 0;
@@ -78,14 +76,12 @@
int size = d->in.size();
if ( parsedBytes < size )
{
- // copy the unparsed bytes into a new qbytearray and replace d->in with that
- QByteArray remainder( size - parsedBytes, char(' ') );
- memcpy( remainder.data(), d->in.data() + parsedBytes, remainder.size() );
- d->in = remainder;
+ // Remove the parsed bytes and keep the old ones.
+ d->in = d->in.right( size - parsedBytes );
}
else
{
- d->in.truncate( 0 );
+ d->in.clear();
}
}
@@ -198,7 +194,7 @@
void HttpCoreProtocol::reset()
{
- d->in.resize( 0 );
+ d->in.clear();
}
bool HttpCoreProtocol::okToProceed(const QDataStream &din)
--- trunk/KDE/kdenetwork/kopete/protocols/messenger/libpapillon/messengercoreprotocol.cpp #619559:619560
@@ -68,12 +68,10 @@
void MessengerCoreProtocol::addIncomingData(const QByteArray &incomingBytes )
{
- // store locally
- int oldsize = d->in.size();
- d->in.resize( oldsize + incomingBytes.size() );
- memcpy( d->in.data() + oldsize, incomingBytes.data(), incomingBytes.size() );
-
- // convert every event in the chunk to a Transfer, signalling it back to the clientstream
+ // Append incoming bytes to incoming buffer
+ d->in += incomingBytes;
+
+ // convert every event in the chunk to a Transfer, signalling it back to the ClientStream
int parsedBytes = 0;
int transferCount = 0;
// while there is data left in the input buffer, and we are able to parse something out of it
@@ -83,17 +81,14 @@
int size = d->in.size();
if ( parsedBytes < size )
{
- // copy the unparsed bytes into a new qbytearray and replace d->in with that
- QByteArray remainder( size - parsedBytes, ' ' );
- memcpy( remainder.data(), d->in.data() + parsedBytes, remainder.size() );
- d->in = remainder;
+ // Remove the parsed bytes and keep the old ones.
+ d->in = d->in.right( size - parsedBytes );
}
else
{
d->in.clear();
}
}
-
}
Transfer *MessengerCoreProtocol::incomingTransfer()
@@ -229,7 +224,7 @@
void MessengerCoreProtocol::reset()
{
- d->in.resize( 0 );
+ d->in.clear();
}
bool MessengerCoreProtocol::okToProceed(const QDataStream &din)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic