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: Repeatedly allocates and frees a chunk of memory, to verify
10** that free is really returning memory to the heap
11**
12**
13**==========================================================================*/
14
15#include <palsuite.h>
16
17int __cdecl main(int argc, char **argv)
18{
19
20 char *testA;
21
22 long i;
23 if (PAL_Initialize(argc, argv))
24 {
25 return FAIL;
26 }
27
28
29 /* check that free really returns memory to the heap. */
30 for(i=1; i<1000000; i++)
31 {
32 testA = (char *)malloc(1000*sizeof(char));
33 if (testA==NULL)
34 {
35 Fail("Either free is failing to return memory to the heap, or"
36 " the system is running out of memory for some other "
37 "reason.\n");
38 }
39 free(testA);
40 }
41
42 free(NULL); /*should do nothing*/
43 PAL_Terminate();
44 return PASS;
45}
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63