What is Trailing Array Idiom ?
P.S : Googling this term gives The vectors are implemented using the trailing array idiom, thus they are not resizeable without changing the address of the vector object itself.
If you mean the trailing array idiom mentioned in the GCC source code (where your quote comes from), it seems to refer to the old C trick to implement a dynamic array:
typedef struct {
/* header */
size_t nelems;
/* actual array */
int a[1];
} IntVector;
where an array would be created with
IntVector *make_intvector(size_t n)
{
IntVector *v = malloc(sizeof(IntVector) + sizeof(int) * (n-1));
if (v != NULL)
v->nelems = n;
return v;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With