aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/NativeHeapApi/src/NativeHeapApi.h22
-rw-r--r--lib/WinRpMalloc/src/dllmain.c10
-rw-r--r--lib/WinRpMalloc/src/package.json2
3 files changed, 23 insertions, 11 deletions
diff --git a/lib/NativeHeapApi/src/NativeHeapApi.h b/lib/NativeHeapApi/src/NativeHeapApi.h
index 5e83108..00ca2b8 100644
--- a/lib/NativeHeapApi/src/NativeHeapApi.h
+++ b/lib/NativeHeapApi/src/NativeHeapApi.h
@@ -27,6 +27,18 @@
/*
* Method calling convention for export
*/
+#ifndef HEAP_METHOD_CC
+ #ifdef WIN32
+ #define HEAP_METHOD_CC __stdcall
+ #else
+ #define HEAP_METHOD_CC
+ #endif // WIN32
+#endif // !HEAP_METHOD_CC
+
+
+/*
+* Decorator for exporting methods for dll usage
+*/
#ifndef HEAP_METHOD_EXPORT
#ifdef WIN32
#define HEAP_METHOD_EXPORT __declspec(dllexport)
@@ -81,13 +93,13 @@ 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 heapCreate(UnmanagedHeapFlags* flags);
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapFlags* flags);
/// <summary>
/// Destroys a previously created heap
/// </summary>
/// <param name="heap">The pointer to your custom heap structure from heap creation</param>
-HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap);
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapDestroy(LPVOID heap);
/// <summary>
/// Allocates a block from the desired heap and returns a pointer
@@ -98,7 +110,7 @@ HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap);
/// <param name="alignment">The alignment (or size) of each element in bytes</param>
/// <param name="zero">A flag to zero the block before returning the block</param>
/// <returns>A pointer to the allocated block</returns>
-HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero);
+HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero);
/// <summary>
/// Reallocates a block on the desired heap and returns a pointer to the new block. If reallocation
@@ -111,7 +123,7 @@ HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignme
/// <param name="alignment">The element size or block alignment</param>
/// <param name="zero">A flag to zero the block (or the new size) before returning.</param>
/// <returns>A pointer to the reallocated block, or zero if the operation failed or is not supported</returns>
-HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero);
+HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero);
/// <summary>
/// Frees a previously allocated block on the desired heap.
@@ -119,6 +131,6 @@ HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements
/// <param name="heap">A pointer to your heap structure</param>
/// <param name="block">A pointer to the block to free</param>
/// <returns>A value that indicates the result of the operation, nonzero if success, 0 if a failure occurred </returns>
-HEAP_METHOD_EXPORT ERRNO heapFree(LPVOID heap, LPVOID block);
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapFree(LPVOID heap, LPVOID block);
#endif // !NATIVE_HEAP_API \ No newline at end of file
diff --git a/lib/WinRpMalloc/src/dllmain.c b/lib/WinRpMalloc/src/dllmain.c
index 1c1378e..adcf3e6 100644
--- a/lib/WinRpMalloc/src/dllmain.c
+++ b/lib/WinRpMalloc/src/dllmain.c
@@ -52,7 +52,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
//Define the heap methods
-HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags)
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapCreate(UnmanagedHeapFlags* flags)
{
//Check flags
if (flags->CreationFlags & HEAP_CREATION_IS_SHARED)
@@ -77,7 +77,7 @@ HEAP_METHOD_EXPORT ERRNO heapCreate(UnmanagedHeapFlags* flags)
}
-HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap)
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapDestroy(LPVOID heap)
{
//Destroy the heap
if ((int)heap == GLOBAL_HEAP_HANDLE_VALUE)
@@ -96,7 +96,7 @@ HEAP_METHOD_EXPORT ERRNO heapDestroy(LPVOID heap)
}
-HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero)
+HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapAlloc(LPVOID heap, size_t elements, size_t alignment, BOOL zero)
{
//Multiply for element size
size_t size = elements * alignment;
@@ -138,7 +138,7 @@ HEAP_METHOD_EXPORT LPVOID heapAlloc(LPVOID heap, size_t elements, size_t alignme
}
-HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero)
+HEAP_METHOD_EXPORT LPVOID HEAP_METHOD_CC heapRealloc(LPVOID heap, LPVOID block, size_t elements, size_t alignment, BOOL zero)
{
//Multiply for element size
size_t size = elements * alignment;
@@ -164,7 +164,7 @@ HEAP_METHOD_EXPORT LPVOID heapRealloc(LPVOID heap, LPVOID block, size_t elements
}
-HEAP_METHOD_EXPORT ERRNO heapFree(LPVOID heap, LPVOID block)
+HEAP_METHOD_EXPORT ERRNO HEAP_METHOD_CC heapFree(LPVOID heap, LPVOID block)
{
//Check for global heap
if ((int)heap == GLOBAL_HEAP_HANDLE_VALUE)
diff --git a/lib/WinRpMalloc/src/package.json b/lib/WinRpMalloc/src/package.json
index 35a1ca6..7ee361e 100644
--- a/lib/WinRpMalloc/src/package.json
+++ b/lib/WinRpMalloc/src/package.json
@@ -2,7 +2,7 @@
"Description": "A project to maintain an x64 Windows dll for RpMalloc by Mattias Jansson with some basic defaults for .NET loading. The debug output contains the debug MVCR libs and debug symbols.",
"Authors": "Vaughn Nugent",
"Copyright": "Copyright &copy; 2023 Vaughn Nugent",
- "Version": "0.1.1",
+ "Version": "0.1.2",
"Company": "Vaughn Nugent",
"Product": "WinRpMalloc",
"RepositoryUrl": "https://github.com/VnUgE/VNLib.Core/tree/main/lib/WinRpMalloc"