mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
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:
parent
b47badb3ee
commit
e229dbe9dc
12
src/osal.c
12
src/osal.c
@ -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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user