summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aapl/bubblesort.h8
-rw-r--r--src/aapl/insertsort.h6
-rw-r--r--src/aapl/mergesort.h11
-rw-r--r--src/aapl/quicksort.h10
-rw-r--r--src/aapl/svector.h10
-rw-r--r--src/aapl/vector.h14
-rw-r--r--test/rlparse.d/vector.h14
7 files changed, 38 insertions, 35 deletions
diff --git a/src/aapl/bubblesort.h b/src/aapl/bubblesort.h
index 42482991..2322a0c3 100644
--- a/src/aapl/bubblesort.h
+++ b/src/aapl/bubblesort.h
@@ -23,6 +23,8 @@
#ifndef _AAPL_BUBBLESORT_H
#define _AAPL_BUBBLESORT_H
+#include <string.h>
+
#ifdef AAPL_NAMESPACE
namespace Aapl {
#endif
@@ -77,9 +79,9 @@ template <class T, class Compare> void BubbleSort<T,Compare>::
char tmp[sizeof(T)];
/* Swap the two items. */
- memcpy( tmp, data+i, sizeof(T) );
- memcpy( data+i, data+i+1, sizeof(T) );
- memcpy( data+i+1, tmp, sizeof(T) );
+ memcpy( tmp, (void*)(data+i), sizeof(T) );
+ memcpy( (void*)(data+i), (void*)(data+i+1), sizeof(T) );
+ memcpy( (void*)(data+i+1), tmp, sizeof(T) );
/* Note that we made a change. */
changed = true;
diff --git a/src/aapl/insertsort.h b/src/aapl/insertsort.h
index 386fd9c6..6040f20f 100644
--- a/src/aapl/insertsort.h
+++ b/src/aapl/insertsort.h
@@ -81,9 +81,9 @@ template <class T, class Compare>
if ( smallest != dest ) {
/* Swap dest, smallest. */
char tmp[sizeof(T)];
- memcpy( tmp, dest, sizeof(T) );
- memcpy( dest, smallest, sizeof(T) );
- memcpy( smallest, tmp, sizeof(T) );
+ memcpy( tmp, (void*)dest, sizeof(T) );
+ memcpy( (void*)dest, (void*)smallest, sizeof(T) );
+ memcpy( (void*)smallest, tmp, sizeof(T) );
}
}
}
diff --git a/src/aapl/mergesort.h b/src/aapl/mergesort.h
index 83f8b67b..53bcc675 100644
--- a/src/aapl/mergesort.h
+++ b/src/aapl/mergesort.h
@@ -24,6 +24,7 @@
#define _AAPL_MERGESORT_H
#include "bubblesort.h"
+#include <string.h>
#ifdef AAPL_NAMESPACE
namespace Aapl {
@@ -100,26 +101,26 @@ template< class T, class Compare> void MergeSort<T,Compare>::
if ( lower == endLower ) {
/* Possibly upper left. */
if ( upper != endUpper )
- memcpy( dest, upper, (endUpper - upper) * sizeof(T) );
+ memcpy( (void*)dest, (void*)upper, (endUpper - upper) * sizeof(T) );
break;
}
else if ( upper == endUpper ) {
/* Only lower left. */
if ( lower != endLower )
- memcpy( dest, lower, (endLower - lower) * sizeof(T) );
+ memcpy( (void*)dest, (void*)lower, (endLower - lower) * sizeof(T) );
break;
}
else {
/* Both upper and lower left. */
if ( this->compare(*lower, *upper) <= 0 )
- memcpy( dest++, lower++, sizeof(T) );
+ memcpy( (void*)(dest++), (void*)(lower++), sizeof(T) );
else
- memcpy( dest++, upper++, sizeof(T) );
+ memcpy( (void*)(dest++), (void*)(upper++), sizeof(T) );
}
}
/* Copy back from the tmpStor array. */
- memcpy( data, tmpStor, sizeof( T ) * len );
+ memcpy( (void*)data, (void*)tmpStor, sizeof( T ) * len );
}
/**
diff --git a/src/aapl/quicksort.h b/src/aapl/quicksort.h
index f23ec2ee..3708db2a 100644
--- a/src/aapl/quicksort.h
+++ b/src/aapl/quicksort.h
@@ -113,9 +113,9 @@ template <class T, class Compare> T *QuickSort<T,Compare>::
char pcPivot[sizeof(T)];
T *pivot = median(start, end);
- memcpy( pcPivot, pivot, sizeof(T) );
+ memcpy( pcPivot, (void*)pivot, sizeof(T) );
if ( pivot != end )
- memcpy( pivot, end, sizeof(T) );
+ memcpy( (void*)pivot, (void*)end, sizeof(T) );
T *first = start-1;
T *last = end;
@@ -130,7 +130,7 @@ template <class T, class Compare> T *QuickSort<T,Compare>::
if ( first == last )
goto done;
if ( this->compare( *first, *pivot ) > 0 ) {
- memcpy(last, first, sizeof(T));
+ memcpy((void*)last, (void*)first, sizeof(T));
break;
}
}
@@ -141,14 +141,14 @@ template <class T, class Compare> T *QuickSort<T,Compare>::
if ( last == first )
goto done;
if ( this->compare( *last, *pivot ) < 0 ) {
- memcpy(first, last, sizeof(T));
+ memcpy((void*)first, (void*)last, sizeof(T));
break;
}
}
}
done:
/* Put the pivot into the middle spot for it. */
- memcpy( first, pivot, sizeof(T) );
+ memcpy( (void*)first, (void*)pivot, sizeof(T) );
return first;
}
diff --git a/src/aapl/svector.h b/src/aapl/svector.h
index 54db2007..d0ff2737 100644
--- a/src/aapl/svector.h
+++ b/src/aapl/svector.h
@@ -674,7 +674,7 @@ template <class T, class Resize> void SVector<T, Resize>::
head->allocLen = newLen;
/* Table exists already, resize it up. */
- head = (STabHead*) realloc( head, sizeof(STabHead) +
+ head = (STabHead*) realloc( (void*)head, sizeof(STabHead) +
sizeof(T) * newLen );
if ( head == 0 )
throw std::bad_alloc();
@@ -765,7 +765,7 @@ template <class T, class Resize> void SVector<T, Resize>::
head->allocLen = newLen;
/* Not shrinking to size zero, realloc it to the smaller size. */
- head = (STabHead*) realloc( head, sizeof(STabHead) +
+ head = (STabHead*) realloc( (void*)head, sizeof(STabHead) +
sizeof(T) * newLen );
if ( head == 0 )
throw std::bad_alloc();
@@ -1132,7 +1132,7 @@ template <class T, class Resize> void SVector<T, Resize>::
/* Shift data over if necessary. */
long lenToSlideOver = head->tabLen - endPos;
if ( len > 0 && lenToSlideOver > 0 )
- memmove(BaseTable::data + pos, dst + len, sizeof(T)*lenToSlideOver);
+ memmove((void*)(BaseTable::data + pos), (void*)(dst + len), sizeof(T)*lenToSlideOver);
/* Shrink the data if necessary. */
downResize( newLen );
@@ -1192,7 +1192,7 @@ template <class T, class Resize> long SVector<T, Resize>::
/* Shift over data at insert spot if needed. */
if ( len > 0 && pos < head->tabLen ) {
- memmove( BaseTable::data + pos + len, BaseTable::data + pos,
+ memmove( (void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos),
sizeof(T)*(head->tabLen - pos) );
}
@@ -1312,7 +1312,7 @@ template <class T, class Resize> void SVector<T, Resize>::
/* Shift over data at insert spot if needed. */
if ( len > 0 && pos < head->tabLen ) {
- memmove( BaseTable::data + pos + len, BaseTable::data + pos,
+ memmove( (void*)(BaseTable::data + pos + len), (void*)(BaseTable::data + pos),
sizeof(T)*(head->tabLen - pos) );
}
diff --git a/src/aapl/vector.h b/src/aapl/vector.h
index 0ec385d5..64458897 100644
--- a/src/aapl/vector.h
+++ b/src/aapl/vector.h
@@ -656,7 +656,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();
}
@@ -687,7 +687,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();
}
@@ -1038,7 +1038,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 );
@@ -1072,7 +1072,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));
}
@@ -1111,7 +1111,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));
}
@@ -1148,7 +1148,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));
}
@@ -1175,7 +1175,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));
}
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));
}