binutils-gdb/libiberty/memset.c

31 lines
590 B
C
Raw Normal View History

1999-05-03 15:29:11 +08:00
/* memset
This implementation is in the public domain. */
2001-09-27 02:45:50 +08:00
/*
@deftypefn Supplemental void* memset (void *@var{s}, int @var{c}, size_t @var{count})
Sets the first @var{count} bytes of @var{s} to the constant byte
@var{c}, returning a pointer to @var{s}.
@end deftypefn
*/
1999-05-03 15:29:11 +08:00
#include <ansidecl.h>
#ifdef __STDC__
#include <stddef.h>
#else
#define size_t unsigned long
#endif
PTR
DEFUN(memset, (dest, val, len),
PTR dest AND register int val AND register size_t len)
{
register unsigned char *ptr = (unsigned char*)dest;
while (len-- > 0)
*ptr++ = val;
return dest;
}