Source code of Windows XP (NT5)
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.

59 lines
1.5 KiB

  1. /***
  2. *memset.c - set a section of memory to all one byte
  3. *
  4. * Copyright (c) 1988-1997, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * contains the memset() routine
  8. *
  9. *******************************************************************************/
  10. //#include <cruntime.h>
  11. #include <string.h>
  12. #ifdef _MSC_VER
  13. #pragma function(memset)
  14. #endif /* _MSC_VER */
  15. /***
  16. *char *memset(dst, val, count) - sets "count" bytes at "dst" to "val"
  17. *
  18. *Purpose:
  19. * Sets the first "count" bytes of the memory starting
  20. * at "dst" to the character value "val".
  21. *
  22. *Entry:
  23. * void *dst - pointer to memory to fill with val
  24. * int val - value to put in dst bytes
  25. * size_t count - number of bytes of dst to fill
  26. *
  27. *Exit:
  28. * returns dst, with filled bytes
  29. *
  30. *Exceptions:
  31. *
  32. *******************************************************************************/
  33. void * __cdecl memset (
  34. void *dst,
  35. int val,
  36. size_t count
  37. )
  38. {
  39. void *start = dst;
  40. #if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
  41. {
  42. extern void RtlFillMemory( void *, size_t count, char );
  43. RtlFillMemory( dst, count, (char)val );
  44. }
  45. #else /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  46. while (count--) {
  47. *(char *)dst = (char)val;
  48. dst = (char *)dst + 1;
  49. }
  50. #endif /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  51. return(start);
  52. }