mdbx-windows: add mdbx_strdup() to avoid dependency from CRT.

12 of 17 for https://github.com/leo-yuriev/libmdbx/issues/43

Change-Id: Ib1379d75dc25e34f56daf8988848c41f59b6cd6b
This commit is contained in:
Leonid Yuriev 2018-10-14 11:24:59 +03:00
parent b47badb3ee
commit e229dbe9dc
2 changed files with 15 additions and 6 deletions

View File

@ -288,6 +288,18 @@ void mdbx_memalign_free(void *ptr) {
}
#endif /* mdbx_memalign_free */
#ifndef mdbx_strdup
char *mdbx_strdup(const char *str) {
if (!str)
return NULL;
size_t bytes = strlen(str) + 1;
char *dup = mdbx_malloc(bytes);
if (dup)
memcpy(dup, str, bytes);
return dup;
}
#endif /* mdbx_strdup */
/*----------------------------------------------------------------------------*/
int mdbx_condmutex_init(mdbx_condmutex_t *condmutex) {

View File

@ -119,6 +119,7 @@ typedef pthread_mutex_t mdbx_fastmutex_t;
#define mdbx_calloc calloc
#define mdbx_realloc realloc
#define mdbx_free free
#define mdbx_strdup strdup
#endif /* Platform */
/* *INDENT-OFF* */
@ -422,13 +423,9 @@ static __inline size_t mdbx_syspagesize(void) {
#endif
}
static __inline char *mdbx_strdup(const char *str) {
#ifdef _MSC_VER
return _strdup(str);
#else
return strdup(str);
#ifndef mdbx_strdup
char *mdbx_strdup(const char *str);
#endif
}
static __inline int mdbx_get_errno(void) {
#if defined(_WIN32) || defined(_WIN64)