summaryrefslogtreecommitdiffstats
path: root/private/crt32/string/memset.c
blob: 5a04554a938356a19990015fa4cb800c717f84ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/***
*memset.c - set a section of memory to all one byte
*
*	Copyright (c) 1988-1991, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	contains the memset() routine
*
*Revision History:
*	05-31-89   JCR	C version created.
*	02-27-90   GJF	Fixed calling type, #include <cruntime.h>, fixed
*			copyright.
*	08-14-90   SBM	Compiles cleanly with -W3
*	10-01-90   GJF	New-style function declarator. Also, rewrote expr. to
*			avoid using cast as an lvalue.
*       04-01-91  SRW   Add #pragma function for i386 _WIN32_ and _CRUISER_
*                       builds
*       07-16-93  SRW   ALPHA Merge
*
*******************************************************************************/

#include <cruntime.h>
#include <string.h>

#ifdef	_MSC_VER
#pragma function(memset)
#endif

/***
*char *memset(dst, val, count) - sets "count" bytes at "dst" to "val"
*
*Purpose:
*	Sets the first "count" bytes of the memory starting
*	at "dst" to the character value "val".
*
*Entry:
*	void *dst - pointer to memory to fill with val
*	int val   - value to put in dst bytes
*	size_t count - number of bytes of dst to fill
*
*Exit:
*	returns dst, with filled bytes
*
*Exceptions:
*
*******************************************************************************/

void * _CALLTYPE1 memset (
	void *dst,
	int val,
	size_t count
	)
{
	void *start = dst;

#if	defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC)
        {
        extern void RtlFillMemory( void *, size_t count, char );

        RtlFillMemory( dst, count, (char)val );
        }
#else
	while (count--) {
		*(char *)dst = (char)val;
		dst = (char *)dst + 1;
	}
#endif

	return(start);
}