| 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: LocalAlloc.c |
| 8 | ** |
| 9 | ** Purpose: Positive test the LocalAlloc API. |
| 10 | ** Call LocalAlloc with zero as the allocation attribute |
| 11 | ** |
| 12 | ** |
| 13 | **============================================================*/ |
| 14 | #include <palsuite.h> |
| 15 | |
| 16 | int __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 allocation attribute: zero which is required by PAL Doc*/ |
| 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 | |