summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp')
-rw-r--r--src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp
new file mode 100644
index 0000000000..17afbc6020
--- /dev/null
+++ b/src/pal/tests/palsuite/filemapping_memmgt/LocalAlloc/test1/LocalAlloc.cpp
@@ -0,0 +1,49 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more 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;
+}