diff options
author | Adrian Thurston <thurston@colm.net> | 2020-12-09 10:02:50 -0800 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2020-12-09 10:06:03 -0800 |
commit | 368a8d850061dcae69bf2f7a7b2dc9ef209de2c9 (patch) | |
tree | 2e9ec7ea3d808686ce48fc997446353f8b05b810 /test | |
parent | dc32f819872e045b71015b424a77ed645f914769 (diff) | |
download | colm-368a8d850061dcae69bf2f7a7b2dc9ef209de2c9.tar.gz |
casting template type pointers to void* before passing to memmove funcs
More recent compilers will now warn about moving and copying non-trivial types,
due to the potential for internal pointers. This is a risk the libraries always
had, and it is expected to not put those things into the containers. Casting to
void* removes the new warnings and better expresses what the code is doing.
Diffstat (limited to 'test')
-rw-r--r-- | test/rlparse.d/vector.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/test/rlparse.d/vector.h b/test/rlparse.d/vector.h index b29c7496..14293de9 100644 --- a/test/rlparse.d/vector.h +++ b/test/rlparse.d/vector.h @@ -651,7 +651,7 @@ template<class T, class Resize> void Vector<T, Resize>:: BaseTable::allocLen = newLen; if ( BaseTable::data != 0 ) { /* Table exists already, resize it up. */ - BaseTable::data = (T*) realloc( BaseTable::data, sizeof(T) * newLen ); + BaseTable::data = (T*) realloc( (void*)BaseTable::data, sizeof(T) * newLen ); if ( BaseTable::data == 0 ) throw std::bad_alloc(); } @@ -682,7 +682,7 @@ template<class T, class Resize> void Vector<T, Resize>:: } else { /* Not shrinking to size zero, realloc it to the smaller size. */ - BaseTable::data = (T*) realloc( BaseTable::data, sizeof(T) * newLen ); + BaseTable::data = (T*) realloc( (void*)BaseTable::data, sizeof(T) * newLen ); if ( BaseTable::data == 0 ) throw std::bad_alloc(); } @@ -1033,7 +1033,7 @@ template<class T, class Resize> void Vector<T, Resize>:: /* Shift data over if necessary. */ lenToSlideOver = BaseTable::tabLen - endPos; if ( len > 0 && lenToSlideOver > 0 ) - memmove(dst, dst + len, sizeof(T)*lenToSlideOver); + memmove((void*)dst, (void*)(dst + len), sizeof(T)*lenToSlideOver); /* Shrink the data if necessary. */ downResize( newLen ); @@ -1067,7 +1067,7 @@ template<class T, class Resize> void Vector<T, Resize>:: /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { - memmove(BaseTable::data + pos + len, BaseTable::data + pos, + memmove((void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos), sizeof(T)*(BaseTable::tabLen-pos)); } @@ -1106,7 +1106,7 @@ template<class T, class Resize> void Vector<T, Resize>:: /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { - memmove(BaseTable::data + pos + len, BaseTable::data + pos, + memmove((void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos), sizeof(T)*(BaseTable::tabLen-pos)); } @@ -1143,7 +1143,7 @@ template<class T, class Resize> void Vector<T, Resize>:: /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { - memmove(BaseTable::data + pos + len, BaseTable::data + pos, + memmove((void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos), sizeof(T)*(BaseTable::tabLen-pos)); } @@ -1170,7 +1170,7 @@ template<class T, class Resize> void Vector<T, Resize>:: /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { - memmove(BaseTable::data + pos + len, BaseTable::data + pos, + memmove((void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos), sizeof(T)*(BaseTable::tabLen-pos)); } |