mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
bug #1170: skip calls to memcpy/memmove for empty imput.
This commit is contained in:
parent
6f0992c05b
commit
6fa35bbd28
@ -486,7 +486,12 @@ template<typename T> EIGEN_DEVICE_FUNC void smart_copy(const T* start, const T*
|
||||
|
||||
template<typename T> struct smart_copy_helper<T,true> {
|
||||
EIGEN_DEVICE_FUNC static inline void run(const T* start, const T* end, T* target)
|
||||
{ memcpy(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
|
||||
{
|
||||
std::ptrdiff_t size = std::ptrdiff_t(end)-std::ptrdiff_t(start);
|
||||
if(size==0) return;
|
||||
eigen_internal_assert(start!=0 && end!=0 && target!=0);
|
||||
memcpy(target, start, size);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct smart_copy_helper<T,false> {
|
||||
@ -504,7 +509,12 @@ template<typename T> void smart_memmove(const T* start, const T* end, T* target)
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,true> {
|
||||
static inline void run(const T* start, const T* end, T* target)
|
||||
{ std::memmove(target, start, std::ptrdiff_t(end)-std::ptrdiff_t(start)); }
|
||||
{
|
||||
std::ptrdiff_t size = std::ptrdiff_t(end)-std::ptrdiff_t(start);
|
||||
if(size==0) return;
|
||||
eigen_internal_assert(start!=0 && end!=0 && target!=0);
|
||||
std::memmove(target, start, size);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T> struct smart_memmove_helper<T,false> {
|
||||
|
Loading…
Reference in New Issue
Block a user