[Interest] Transfering ownership of QByteArray to char*

Thiago Macieira thiago.macieira at intel.com
Mon Aug 20 10:46:20 CEST 2012


On segunda-feira, 20 de agosto de 2012 10.14.07, Thiago Macieira wrote:
> On segunda-feira, 20 de agosto de 2012 12.01.59, Konstantin Tokarev wrote:
> > Hi all,
> > 
> > Is there a safe way to get char * from QByteArray which is not destroyed
> > when original QByteArray is destroyed?
> > 
> > I'm thinking about something like
> > 
> > QByteArray ba = ...;
> > char *data = ba.data();
> > ba.data() = '\0';
> 
> That is safe.

Oh, I misread what you said.

You want to keep a copy when the original *is* destroyed. I read "while it 
isn't" somehow.

Like Lars said, make your own copy.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120820/3d3cb743/attachment.sig>


More information about the Interest mailing list