On Wednesday 22 July 2015 10:25:02 [email protected] wrote:
> By the way, is it possible to add custom allocators to the vector? As we
> have to store reference counter (at least) with the data, wouldn't there be
> problems with aligning of the memory?

Allocators is a feature we've never supported and I don't see us supporting.

I don't see a problem with the alignment. QArrayData is allocated with 
alignment of min(alignof(QArrayData), alignof(T)), then we find the proper 
alignment for T inside the buffer and that should be enough.

>From qarraydata.cpp:

    // Allocate extra (alignment - Q_ALIGNOF(QArrayData)) padding bytes so we
    // can properly align the data array. This assumes malloc is able to
    // provide appropriate alignment for the header -- as it should!
    // Padding is skipped when allocating a header for RawData.
    if (!(options & RawData))
        headerSize += (alignment - Q_ALIGNOF(QArrayData));

[...]
        quintptr data = (quintptr(header) + sizeof(QArrayData) + alignment - 
1)
                & ~(alignment - 1);

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to