[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: About KArchive::data()
From:       David Faure <faure () kde ! org>
Date:       2007-11-05 23:07:50
Message-ID: 200711060007.50989.faure () kde ! org
[Download RAW message or body]

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.

-- 
David Faure, faure@kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic