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: Test that malloc returns useable memory
10**
11**
12**==========================================================================*/
13
14#include <palsuite.h>
15
16
17int __cdecl main(int argc, char **argv)
18{
19
20 char *testA;
21 int i;
22 if (PAL_Initialize(argc, argv))
23 {
24 return FAIL;
25 }
26
27 /* check that malloc really gives us addressable memory */
28 testA = (char *)malloc(20 * sizeof(char));
29 if (testA == NULL)
30 {
31 Fail("Call to malloc failed.\n");
32 }
33 for (i = 0; i < 20; i++)
34 {
35 testA[i] = 'a';
36 }
37 for (i = 0; i < 20; i++)
38 {
39 if (testA[i] != 'a')
40 {
41 Fail("The memory doesn't seem to be properly allocated.\n");
42 }
43 }
44 free(testA);
45
46 PAL_Terminate();
47
48 return PASS;
49}
50
51
52
53