Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.9 KiB

  1. /***
  2. *memcpy.c - contains memcpy routine
  3. *
  4. * Copyright (c) 1988-1993, Microsoft Corporation. All right reserved.
  5. *
  6. *Purpose:
  7. * memcpy() copies a source memory buffer to a destination buffer.
  8. * Overlapping buffers are not treated specially, so propogation may occur.
  9. *
  10. *******************************************************************************/
  11. //#include "cruntime.h"
  12. #include <string.h>
  13. #ifdef _MSC_VER
  14. #pragma function(memcpy)
  15. #endif /* _MSC_VER */
  16. /***
  17. *memcpy - Copy source buffer to destination buffer
  18. *
  19. *Purpose:
  20. * memcpy() copies a source memory buffer to a destination memory buffer.
  21. * This routine does NOT recognize overlapping buffers, and thus can lead
  22. * to propogation.
  23. *
  24. * For cases where propogation must be avoided, memmove() must be used.
  25. *
  26. *Entry:
  27. * void *dst = pointer to destination buffer
  28. * const void *src = pointer to source buffer
  29. * size_t count = number of bytes to copy
  30. *
  31. *Exit:
  32. * Returns a pointer to the destination buffer
  33. *
  34. *Exceptions:
  35. *******************************************************************************/
  36. void * __cdecl memcpy (
  37. void * dst,
  38. const void * src,
  39. size_t count
  40. )
  41. {
  42. void * ret = dst;
  43. #if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
  44. {
  45. extern void RtlMoveMemory( void *, const void *, size_t count );
  46. RtlMoveMemory( dst, src, count );
  47. }
  48. #else /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  49. /*
  50. * copy from lower addresses to higher addresses
  51. */
  52. while (count--) {
  53. *(char *)dst = *(char *)src;
  54. dst = (char *)dst + 1;
  55. src = (char *)src + 1;
  56. }
  57. #endif /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  58. return(ret);
  59. }