Add explicit int -> size_t casts to SkTDArray.h

To unblock https://skia-review.googlesource.com/c/skia/+/347616:

In file included from ../../../../../../skia/tools/public_headers_warnings_check.cpp:8:
In file included from gen\skia.h:19:
In file included from ../../../../../../skia\include/core/SkContourMeasure.h:11:
In file included from ../../../../../../skia\include\core\SkPath.h:13:
In file included from ../../../../../../skia\include/private/SkPathRef.h:16:
In file included from ../../../../../../skia\include/private/SkIDChangeListener.h:13:
../../../../../../skia\include/private/SkTDArray.h(76,48): error: implicit conversion changes signedness: 'const int' to 'unsigned long long' [-Werror,-Wsign-conversion]
                 !memcmp(a.fArray, b.fArray, a.fCount * sizeof(T)));
                                             ~~^~~~~~ ~

...

Change-Id: I1b55580ae5e73bde41cecb20d137295bbaf8cbb6
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347860
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Florin Malita <fmalita@google.com>
This commit is contained in:
Florin Malita 2020-12-28 11:17:43 -05:00 committed by Skia Commit-Bot
parent ad48280dd0
commit c8f9f68b07

View File

@ -33,8 +33,8 @@ public:
fReserve = fCount = 0;
fArray = nullptr;
if (count) {
fArray = (T*)sk_malloc_throw(count * sizeof(T));
memcpy(fArray, src, sizeof(T) * count);
fArray = (T*)sk_malloc_throw(SkToSizeT(count) * sizeof(T));
memcpy(fArray, src, sizeof(T) * SkToSizeT(count));
fReserve = fCount = count;
}
}
@ -56,7 +56,7 @@ public:
SkTDArray<T> tmp(src.fArray, src.fCount);
this->swap(tmp);
} else {
sk_careful_memcpy(fArray, src.fArray, sizeof(T) * src.fCount);
sk_careful_memcpy(fArray, src.fArray, sizeof(T) * SkToSizeT(src.fCount));
fCount = src.fCount;
}
}
@ -73,7 +73,7 @@ public:
friend bool operator==(const SkTDArray<T>& a, const SkTDArray<T>& b) {
return a.fCount == b.fCount &&
(a.fCount == 0 ||
!memcmp(a.fArray, b.fArray, a.fCount * sizeof(T)));
!memcmp(a.fArray, b.fArray, SkToSizeT(a.fCount) * sizeof(T)));
}
friend bool operator!=(const SkTDArray<T>& a, const SkTDArray<T>& b) {
return !(a == b);