87 lines
2.2 KiB
C++
87 lines
2.2 KiB
C++
|
#include "precomp.h"
|
||
|
|
||
|
// In debug mode, we link with CRT, so we don't need this!
|
||
|
#ifndef _DEBUG
|
||
|
|
||
|
|
||
|
/***
|
||
|
*memmove.c - contains memmove routine
|
||
|
*
|
||
|
* Copyright (c) 1988-1997, Microsoft Corporation. All right reserved.
|
||
|
*
|
||
|
*Purpose:
|
||
|
* memmove() copies a source memory buffer to a destination buffer.
|
||
|
* Overlapping buffers are treated specially, to avoid propogation.
|
||
|
*
|
||
|
*******************************************************************************/
|
||
|
|
||
|
#if defined (_M_ALPHA)
|
||
|
#pragma function(memmove)
|
||
|
#endif /* defined (_M_ALPHA) */
|
||
|
|
||
|
/***
|
||
|
*memmove - Copy source buffer to destination buffer
|
||
|
*
|
||
|
*Purpose:
|
||
|
* memmove() copies a source memory buffer to a destination memory buffer.
|
||
|
* This routine recognize overlapping buffers to avoid propogation.
|
||
|
* For cases where propogation is not a problem, memcpy() can be used.
|
||
|
*
|
||
|
*Entry:
|
||
|
* void *dst = pointer to destination buffer
|
||
|
* const void *src = pointer to source buffer
|
||
|
* size_t count = number of bytes to copy
|
||
|
*
|
||
|
*Exit:
|
||
|
* Returns a pointer to the destination buffer
|
||
|
*
|
||
|
*Exceptions:
|
||
|
*******************************************************************************/
|
||
|
|
||
|
void * __cdecl memmove (
|
||
|
void * dst,
|
||
|
const void * src,
|
||
|
size_t count
|
||
|
)
|
||
|
{
|
||
|
void * ret = dst;
|
||
|
|
||
|
#if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
|
||
|
{
|
||
|
extern void RtlMoveMemory( void *, const void *, size_t count );
|
||
|
|
||
|
RtlMoveMemory( dst, src, count );
|
||
|
}
|
||
|
#else /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
|
||
|
if (dst <= src || (char *)dst >= ((char *)src + count)) {
|
||
|
/*
|
||
|
* Non-Overlapping Buffers
|
||
|
* copy from lower addresses to higher addresses
|
||
|
*/
|
||
|
while (count--) {
|
||
|
*(char *)dst = *(char *)src;
|
||
|
dst = (char *)dst + 1;
|
||
|
src = (char *)src + 1;
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
/*
|
||
|
* Overlapping Buffers
|
||
|
* copy from higher addresses to lower addresses
|
||
|
*/
|
||
|
dst = (char *)dst + count - 1;
|
||
|
src = (char *)src + count - 1;
|
||
|
|
||
|
while (count--) {
|
||
|
*(char *)dst = *(char *)src;
|
||
|
dst = (char *)dst - 1;
|
||
|
src = (char *)src - 1;
|
||
|
}
|
||
|
}
|
||
|
#endif /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
|
||
|
|
||
|
return(ret);
|
||
|
}
|
||
|
|
||
|
#endif // !_DEBUG
|