[Qt-interest] On overriding qMalloc in QVector
Benoit Jacob
jacob.benoit.1 at gmail.com
Thu Oct 22 20:01:29 CEST 2009
2009/10/22 Thiago Macieira <thiago at kde.org>:
> Em Quinta-feira 22 Outubro 2009, às 16:40:07, você escreveu:
>> We need to pass the alignment requirements from the compiler to the
>> allocator function. So we need a qMallocAligned function.
>
> Unfortunately, that won't work.
>
> I managed to get an aligned QVector data, but the change is not data-
> compatible.
ah ok.
>
> If I put this change in Qt 4.6, then we could have newly-compiled code
> allocating aligned buffers passing a QVector to code that wasn't recompiled. If
> that older code tried to free the vector, the application would most likely
> crash.
>
> I think I can safely make the change for QMap and QHash though. QList isn't
> affected by this issue, while QLinkedList cannot be solved properly (it uses
> new on QLinkedListNode<T>).
hm, since this can't be done for QVector, i'd say don't bother. it
would only make things more complicated.
Somehow the trick of redefining Q_DECL_IMPORT fixes the crash we're
experiencing so we'll just cross fingers and go with that.
Just please consider
- either adding custom allocator support in Qt 5
- or make sure to honor the alignment settings when compiling in
c++1x (new keyword alignof, not yet supported by any compiler that i
know). (Of course you won't be able to require c++1x for another 10
years but you might take advantage of it when it is enabled).
Either solution would satisfy me though the former is more general.
Cheers,
Benoit
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Senior Product Manager - Nokia, Qt Development Frameworks
> PGP/GPG: 0x6EF45358; fingerprint:
> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list