Re: [AGGREGATED PATCH] Fix in-place editing functions in convert.c
- From
Dmitry Potapov <dpotapov@gmail.com>
- Date
- Oct 5, 2007, 19:27 UTC
- Message-ID
- <37fcd2780710051227n96d29a9v543831ca8292c862@mail.gmail.com>
- In-Reply-To
- <alpine.LFD.0.999.0710051036282.23684@woody.linux-foundation.org>
On 10/5/07, Linus Torvalds <torvalds@linux-foundation.org> wrote:
Show 6 quoted lines
> - Qt (QString): QString::"data()", "ascii()" or "utf8()" or something. > > At least this has the excuse of really being able to handle different > locales (it didn't do that originally, though!), but they end up having > a million helper functions exactly because you cannot use the normal > string routines on anything!
I am afraid you cannot allow the direct access to the internal buffer of a string if this buffer can be implicitly shared between different instances as it is the case with QString. Because when you want to make some modification or want to get a non-const pointer to this buffer, its content has to be copied if the buffer is shared between a few copies.
On the other hand, I don't see what is the problem with using C string routines with it. ::data() returns a pointer and :capacity () returns allocated size of the buffer. ::resize() changes the size of the string. If you need a greater allocated size, you can use ::reserve(). Or did I miss something?
Dmitry