About KArchive::data()
Szombathelyi György
gyurco at freemail.hu
Tue Nov 6 23:01:57 GMT 2007
Ezzel a dátummal: Tuesday 06 November 2007 00.07.50 David Faure ezt írta:
> On Monday 05 November 2007, Szombathelyi György wrote:
> > Hello,
> >
> > I've got some problem about KArchive::data() method:
> > If the file is rather large, this method tries to return the whole file
> > in one QByteArray. That could easily fill all the available memory, trash
> > the disk till the system runs out of swap space.
>
> Yes, it is documented to be so. The recommended way to read a file from an
> archive is to use createDevice() and read from that device - no data
> copying, and no huge memory allocation.
>
> > I suggest changing it to "QByteArray
> > KArchive::data(qint64 size)", where size means the chunk size which
> > should be returned. The caller should call data(size) till the returned
> > QByteArray.isEmpty().
>
> This is bad API since it's state-based IMHO. And after all the QIODevice
> API has all we need for reading chunks already.
Oh, I see now...That's very correct. So my next idea is to delete the data()
method so no-one can even think of using it. Thanks for the clarification!
Bye,
György
More information about the kde-core-devel
mailing list