am ba2c2a8c: am cb2d0c5a: am 7015b3be: Merge "TypeHelpers.h: Don\'t underflow unsigned int"
* commit 'ba2c2a8c70f6838f37cb891c189f4e239bcc9036':
TypeHelpers.h: Don't underflow unsigned int
diff --git a/include/utils/TypeHelpers.h b/include/utils/TypeHelpers.h
index 13c9081..61d618e 100644
--- a/include/utils/TypeHelpers.h
+++ b/include/utils/TypeHelpers.h
@@ -131,7 +131,8 @@
template<typename TYPE> inline
void construct_type(TYPE* p, size_t n) {
if (!traits<TYPE>::has_trivial_ctor) {
- while (n--) {
+ while (n > 0) {
+ n--;
new(p++) TYPE;
}
}
@@ -140,7 +141,8 @@
template<typename TYPE> inline
void destroy_type(TYPE* p, size_t n) {
if (!traits<TYPE>::has_trivial_dtor) {
- while (n--) {
+ while (n > 0) {
+ n--;
p->~TYPE();
p++;
}
@@ -150,7 +152,8 @@
template<typename TYPE> inline
void copy_type(TYPE* d, const TYPE* s, size_t n) {
if (!traits<TYPE>::has_trivial_copy) {
- while (n--) {
+ while (n > 0) {
+ n--;
new(d) TYPE(*s);
d++, s++;
}
@@ -162,12 +165,14 @@
template<typename TYPE> inline
void splat_type(TYPE* where, const TYPE* what, size_t n) {
if (!traits<TYPE>::has_trivial_copy) {
- while (n--) {
+ while (n > 0) {
+ n--;
new(where) TYPE(*what);
where++;
}
} else {
- while (n--) {
+ while (n > 0) {
+ n--;
*where++ = *what;
}
}
@@ -182,7 +187,8 @@
} else {
d += n;
s += n;
- while (n--) {
+ while (n > 0) {
+ n--;
--d, --s;
if (!traits<TYPE>::has_trivial_copy) {
new(d) TYPE(*s);
@@ -203,7 +209,8 @@
{
memmove(d,s,n*sizeof(TYPE));
} else {
- while (n--) {
+ while (n > 0) {
+ n--;
if (!traits<TYPE>::has_trivial_copy) {
new(d) TYPE(*s);
} else {