[Kde-pim] [patch] Bug 71549: QGArray::at: Absolute index out of range
Martin Koller
m.koller at surfeu.at
Mon Feb 12 07:44:13 GMT 2007
On Sunday 11 February 2007, Ingo Klöcker wrote:
> array.resize(size);
> - for (int i = 0; i < size; i++)
> - array.at(i) = 0;
> + memset(array.data(), 0, array.size() * sizeof(KMMsgDictEntry
> *)); // faster than a loop
>
> should probably rather be
>
> - array.resize(size);
> - for (int i = 0; i < size; i++)
> - array.at(i) = 0;
> + array.fill( 0, size );
>
> (see http://doc.trolltech.com/3.3/qmemarray.html#fill)
I had a look at the fill() implementation before I used memset, and in fact it
also uses a loop (at least for a 4 byte pointer type).
> Moreover, I suggest to use
> + if ( fileSize - pos < (count * sizeof(Q_UINT32)) ) {
> instead of
> + if ( fileSize < (count * sizeof(Q_UINT32)) ) {
>
> After all there are only ( fileSize - pos ) bytes left to be read from
> the file.
Yes, ok.
--
Best regards/Schöne Grüße
Martin
Computers and Internet gave you freedom.
TCPA would TAKE your FREEDOM! http://www.againsttcpa.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20070212/7e904efa/attachment.sig>
-------------- next part --------------
_______________________________________________
kde-pim mailing list
kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
More information about the kde-pim
mailing list