Fix TArray::push_back when pushing references inside the container.

std::vector<> promises that it is safe to call push_back and pass a
reference from inside the container. (That is, it should not
invalidate the reference when it grows the vector.) We can have this
property as well by restructuring `checkRealloc` into a sequence
of two operations: allocating a new buffer, and copying elements
across from the old container into the new one.

Change-Id: Idada247a509c92983f48b3af3ef7419ed1cb9ac6
Bug: b/40044928
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/765777
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Herb Derby <herb@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
1 file changed