b=856850 add PodMove r=Waldo

--HG--
extra : transplant_source : %27%04%F0%2B%96%1B0%A7%DB%81D%26%81%A0u%C9j%3E%A2%B0
This commit is contained in:
Karl Tomlinson 2013-11-05 13:02:54 +13:00
parent efe1e3c065
commit 3637d636de

View File

@ -133,6 +133,21 @@ PodArrayCopy(T (&dst)[N], const T (&src)[N])
PodCopy(dst, src, N);
}
/**
* Copy the memory for |nelem| T elements from |src| to |dst|. If the two
* memory ranges overlap, then the effect is as if the |nelem| elements are
* first copied from |src| to a temporary array, and then from the temporary
* array to |dst|.
*/
template<typename T>
MOZ_ALWAYS_INLINE static void
PodMove(T* dst, const T* src, size_t nelem)
{
MOZ_ASSERT(nelem <= SIZE_MAX / sizeof(T),
"trying to move an impossible number of elements");
memmove(dst, src, nelem * sizeof(T));
}
/**
* Determine whether the |len| elements at |one| are memory-identical to the
* |len| elements at |two|.