blob: a3472cf84534f5a7475557a812d7b2cab82d3a91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
/*=============================================================
**
** Source: LocalAlloc.c
**
** Purpose: Positive test the LocalAlloc API.
** Call LocalAlloc with zero as the allocation attribute
**
**
**============================================================*/
#include <palsuite.h>
int __cdecl main(int argc, char *argv[])
{
HLOCAL LocalHeap;
HLOCAL FreeHeap;
int err;
const SIZE_T heapSize = 64;
/*Initialize the PAL environment*/
err = PAL_Initialize(argc, argv);
if(0 != err)
{
return FAIL;
}
/*Allocate the specified number of bytes from the heap*/
/*with allocation attribute: zero which is required by PAL Doc*/
LocalHeap = LocalAlloc(0, heapSize);
if(!LocalHeap)
{
Fail("\nFailed to call LocalAlloc API, "
"error code=%u\n", GetLastError());
}
/*Free the allocated local heap memory*/
FreeHeap = LocalFree(LocalHeap);
if(FreeHeap)
{
Fail("Failed to call LocalFree API, "
"error code=%u\n", GetLastError());
}
PAL_Terminate();
return PASS;
}
|