On 01/19/2015 10:52 PM, julien2412 wrote:
However, I'm not sure to understand.
I mean, I thought there were mere array (like in C) with fixed size and
vector or other dynamic containers.
The idea is to allocate only a single block of memory for the fixed-size
"head" of the struct plus the dynamically-sized "tail," by doing
something like
OStoreBTreeNodeData * p = reinterpret_cast<OStoreBTreeNodeData *>(
new char[
offsetof(OStoreBTreeNodeData, m_pData) + k * sizeof(T)]);
That trick is used in quite a number of places across the LO codebase,
the most prominent example being rtl_uString underlying OUString.
I don't know what you mean by "flexible array member" but above all what
about if "n" (so capacityCount()) is 1?
m_pData[1] would be out of bounds, wouldn't it?
if n is 1, the body of the loop
for (sal_uInt16 i = 1; i < n; i++)
will be executed zero times, so there would not be any access to
out-of-bounds m_pData[1].
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.