tweak for GCC, memcpy() -> for-loop

I think GCC with optimization is getting confused about what field of
this union is active, and then triggers a crazy warning about
memcpy()'ing (size_t)-1 bytes.

Reading the rules about unions, I think it might be that really only "="
is ever able to switch which union field is active, and our memcpy()
here really doesn't technically work to change the active field.

Change-Id: Ibe33143161935d5e39b9a2f5d35560e4961056e0
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/257444
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2019-12-02 14:36:22 -06:00 committed by Skia Commit-Bot
parent 0f9df470ca
commit 73ac393064

View File

@ -70,7 +70,9 @@ inline GrWindowRectangles& GrWindowRectangles::operator=(const GrWindowRectangle
SkSafeUnref(this->rec());
fCount = that.fCount;
if (fCount <= kNumLocalWindows) {
memcpy(fLocalWindows, that.fLocalWindows, fCount * sizeof(SkIRect));
for (int i = 0; i < fCount; i++) {
fLocalWindows[i] = that.fLocalWindows[i];
}
} else {
fRec = SkRef(that.fRec);
}