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: LocalFree.c
8**
9** Purpose: Positive test the LocalFree API.
10** Call LocalFree to free a specified local memory object
11**
12**
13**============================================================*/
14#include <palsuite.h>
15
16int __cdecl main(int argc, char *argv[])
17{
18 HLOCAL LocalHeap;
19 HLOCAL FreeHeap;
20 int err;
21 const SIZE_T heapSize = 64;
22
23 /*Initialize the PAL environment*/
24 err = PAL_Initialize(argc, argv);
25 if(0 != err)
26 {
27 return FAIL;
28 }
29
30 /*Allocate the specified number of bytes from the heap*/
31 /*with zero ad the allocation attribute*/
32 LocalHeap = LocalAlloc(0, heapSize);
33 if(!LocalHeap)
34 {
35 Fail("\nFailed to call LocalAlloc API, "
36 "error code=%u\n", GetLastError());
37 }
38
39 /*Free the allocated local heap memory*/
40 FreeHeap = LocalFree(LocalHeap);
41 if(FreeHeap)
42 {
43 Fail("Failed to call LocalFree API, "
44 "error code=%u\n", GetLastError());
45 }
46
47 PAL_Terminate();
48 return PASS;
49}
50