aboutsummaryrefslogtreecommitdiff
path: root/lib/NativeHeapApi
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-03-28 00:30:25 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2023-03-28 00:30:25 -0400
commitcf45636b6216d1b2beaec83bb129a1927f24f608 (patch)
tree97553ecbff6189602c24ad0d600005ecc9f5086c /lib/NativeHeapApi
parent0fe1b687531710071d7c5a85cc59577481a06c9b (diff)
Readme and spelling
Diffstat (limited to 'lib/NativeHeapApi')
-rw-r--r--lib/NativeHeapApi/README.md20
-rw-r--r--lib/NativeHeapApi/src/NativeHeapApi.h6
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/NativeHeapApi/README.md b/lib/NativeHeapApi/README.md
index 5341e63..36d3a6e 100644
--- a/lib/NativeHeapApi/README.md
+++ b/lib/NativeHeapApi/README.md
@@ -6,21 +6,27 @@ Contains necessary API header files for user defined heap dlls. Contains the req
You may copy the [NativeHeapApi.h](src/NativeHeapApi.h) header file into your project and begin implementing the heap methods defined in the header file.
-You must define a constant called **HEAP_METHOD_EXPORT** that defines the method calling convention for proper dll loading for your given platform. On windows, this defaults to `__declspec(dllexport)`.
+You must define a constant called **HEAP_METHOD_EXPORT** that defines the method decordation for proper dll loading for your given platform. On windows, this defaults to `__declspec(dllexport)`.
-When the `heapCreate` method is called, a mutable structure pointer is passed as an argument and expected to be updated by your create method. The VNLib.Utils library implements two types of heaps, a global/shared heap and "private" or "first class" heaps exposed by the Memory namespace. Consumers are allowed to create a private heap to use at will.
+You may optionally define a constant **HEAP_METHOD_CC**, which defines the method calling convention. For a windows target, this defaults to __stdcall, as P/Invoke uses the stdcall calling convention. On other platforms this expands to nothimg and P/Invoke uses the CDECL, the default on most platforms.
-### UnmanagedHeapFlags structure
+When the `heapCreate` method is called, a mutable structure pointer is passed as an argument and expected to be updated by your create method. The VNLib.Utils library implements two types of heaps, a global/shared heap and "private" or "first class" heaps exposed by the Memory namespace. Consumers are allowed to create a private heap to use at will.
-`UnmanagedHeapFlags.HeapPointer` - Set your heap pointer that will be passed to all heap methods
+### Heap architecture
-`UnmanagedHeapFlags.CreationFlags` - Managed creation flags, that may be read and written. The managed heap implementation will observe the result after the `heapCreate` method returns.
+To understand the VNLib.Utils heap architecture, please see the Utils [readme](../Utils/README.md).
-`UnmanagedHeapFlags.Flags` - Generic flags passed by the caller directly to the heapCreate method, not observed or modified by the managed library in any way.
+### UnmanagedHeapDescriptor structure
+
+`UnmanagedHeapDescriptor.HeapPointer` - Set your heap pointer that will be passed to all heap methods
+
+`UnmanagedHeapDescriptor.CreationFlags` - Managed creation flags, that may be read and written. The managed heap implementation will observe the result after the `heapCreate` method returns.
+
+`UnmanagedHeapDescriptor.Flags` - Generic flags passed by the caller directly to the heapCreate method, not observed or modified by the managed library in any way.
### Example Create
``` c
-HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags)
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapDescriptor* flags)
{
//Check flags
if (flags->CreationFlags & HEAP_CREATION_IS_SHARED)
diff --git a/lib/NativeHeapApi/src/NativeHeapApi.h b/lib/NativeHeapApi/src/NativeHeapApi.h
index 00ca2b8..5deca31 100644
--- a/lib/NativeHeapApi/src/NativeHeapApi.h
+++ b/lib/NativeHeapApi/src/NativeHeapApi.h
@@ -80,12 +80,12 @@ typedef void* ERRNO;
/// <summary>
/// A structure for heap initialization
/// </summary>
-typedef struct UnmanagedHeapFlags
+typedef struct UnmanagedHeapDescriptor
{
LPVOID HeapPointer;
HeapCreationFlags CreationFlags;
ERRNO Flags;
-} UnmanagedHeapFlags;
+} UnmanagedHeapDescriptor;
/// <summary>
/// The heap creation method. You must set the flags->HeapPointer = your heap
@@ -93,7 +93,7 @@ typedef struct UnmanagedHeapFlags
/// </summary>
/// <param name="flags">Creation flags passed by the caller to create the heap. This structure will be initialized, and may be modified</param>
/// <returns>A boolean value that indicates the result of the operation</returns>
-HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapFlags* flags);
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapDescriptor* flags);
/// <summary>
/// Destroys a previously created heap