memset.c revision 89857
133965Sjdp/* memset
233965Sjdp   This implementation is in the public domain.  */
333965Sjdp
489857Sobrien/*
589857Sobrien
689857Sobrien@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
789857Sobrien
889857SobrienSets the first @var{count} bytes of @var{s} to the constant byte
989857Sobrien@var{c}, returning a pointer to @var{s}.
1089857Sobrien
1189857Sobrien@end deftypefn
1289857Sobrien
1389857Sobrien*/
1489857Sobrien
1533965Sjdp#include <ansidecl.h>
1633965Sjdp#ifdef __STDC__
1733965Sjdp#include <stddef.h>
1833965Sjdp#else
1933965Sjdp#define size_t unsigned long
2033965Sjdp#endif
2133965Sjdp
2233965SjdpPTR
2333965SjdpDEFUN(memset, (dest, val, len),
2433965Sjdp      PTR dest AND register int val AND register size_t len)
2533965Sjdp{
2633965Sjdp  register unsigned char *ptr = (unsigned char*)dest;
2733965Sjdp  while (len-- > 0)
2833965Sjdp    *ptr++ = val;
2933965Sjdp  return dest;
3033965Sjdp}
31