a.capacity <<= 1u;
decltype(a.data) tmp = (decltype(a.data)) realloc(a.data, sizeof(a.data[0]) * a.capacity);
assert(tmp != NULL);
That's not ideal. Imagine you are at 32GB capacity, the next realloc will ask for 64GB which is pretty excessive.