On Fri, 16 Oct 2009 14:25:44 +0200, Don <nos...@nospam.com> wrote:

>Yes, but you could allocate the data immediately after the Array 
>structure, so you only have one allocation. And in the common case, 
>where it never exceeds the original capacity, they stay together and 
>preserve cache locality.
>
>  void *data;   // = &raw_data;
>  size_t length;
>  size_t capacity; // = 512
>  ubyte[512] raw_data;

Great! And if the length later exceeds the capacity, try to reallocate
in place. If impossible, allocate a new block, copy the data, adjust
the data pointer and shrink the original block to the size of the
Array struct. Right?

Reply via email to