1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*============================================================================
6**
7** Source: test1.c
8**
9** Purpose: Check that memset correctly fills a destination buffer
10** without overflowing it.
11**
12**
13**==========================================================================*/
14
15#include <palsuite.h>
16
17int __cdecl main(int argc, char **argv)
18{
19
20 char testA[22] = "bbbbbbbbbbbbbbbbbbbbb";
21 char *retVal;
22
23 int i;
24 if (PAL_Initialize(argc, argv))
25 {
26 return FAIL;
27 }
28
29 retVal = (char *)memset(testA, 'a', 20);
30 if (retVal != testA)
31 {
32 Fail("memset should have returned the value of the destination"
33 "pointer, but didn't");
34 }
35
36 for(i = 0; i<20; i++)
37 {
38 if (testA[i]!= 'a')
39 {
40 Fail("memset didn't set the destination bytes.\n");
41 }
42 }
43 if (testA[20] == 'a')
44 {
45 Fail("memset overfilled the destination buffer.\n");
46 }
47
48 PAL_Terminate();
49 return PASS;
50}
51
52
53
54
55
56
57
58
59
60
61