diff --git a/dll.vcxproj b/dll.vcxproj
index e808a124..c0743890 100644
--- a/dll.vcxproj
+++ b/dll.vcxproj
@@ -99,7 +99,7 @@
- WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;%(PreprocessorDefinitions);MDBX_DEBUG=1
+ WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;MDBX_AVOID_CRT;%(PreprocessorDefinitions);MDBX_DEBUG=1
MultiThreadedDebugDLL
EnableAllWarnings
ProgramDatabase
@@ -122,7 +122,7 @@
- WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;%(PreprocessorDefinitions)
+ WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;MDBX_AVOID_CRT;%(PreprocessorDefinitions)
MultiThreadedDLL
EnableAllWarnings
ProgramDatabase
@@ -162,7 +162,7 @@
EnableAllWarnings
- WIN64;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;%(PreprocessorDefinitions);MDBX_DEBUG=1
+ WIN64;_DEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;MDBX_AVOID_CRT;%(PreprocessorDefinitions);MDBX_DEBUG=1
MultiThreadedDebugDLL
true
true
@@ -179,7 +179,7 @@
- WIN64;NDEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;%(PreprocessorDefinitions)
+ WIN64;NDEBUG;_WINDOWS;_USRDLL;LIBMDBX_EXPORTS;MDBX_BUILD_DLL;MDBX_AVOID_CRT;%(PreprocessorDefinitions)
MultiThreadedDLL
true
Full
diff --git a/src/osal.c b/src/osal.c
index ef4c03ce..ee5b1f3f 100644
--- a/src/osal.c
+++ b/src/osal.c
@@ -53,7 +53,9 @@ static int ntstatus2errcode(NTSTATUS status) {
* declare them here. Using these APIs also means we must link to
* ntdll.dll, which is not linked by default in user code. */
#pragma comment(lib, "ntdll.lib")
+#ifdef MDBX_AVOID_CRT
#pragma comment(lib, "mdbx_ntdll_extra.lib")
+#endif
extern NTSTATUS NTAPI NtCreateSection(
OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess,
diff --git a/src/osal.h b/src/osal.h
index 414bf19d..7ac226c2 100644
--- a/src/osal.h
+++ b/src/osal.h
@@ -91,6 +91,7 @@ typedef struct {
} mdbx_condmutex_t;
typedef CRITICAL_SECTION mdbx_fastmutex_t;
+#ifdef MDBX_AVOID_CRT
#ifndef mdbx_malloc
static inline void *mdbx_malloc(size_t bytes) {
return LocalAlloc(LMEM_FIXED, bytes);
@@ -112,6 +113,13 @@ static inline void *mdbx_realloc(void *ptr, size_t bytes) {
#ifndef mdbx_free
#define mdbx_free LocalFree
#endif /* mdbx_free */
+#else
+#define mdbx_malloc malloc
+#define mdbx_calloc calloc
+#define mdbx_realloc realloc
+#define mdbx_free free
+#define mdbx_strdup _strdup
+#endif /* MDBX_AVOID_CRT */
#ifndef snprintf
#define snprintf _snprintf /* ntdll */