mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:18:21 +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 */
|
#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) {
|
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_calloc calloc
|
||||||
#define mdbx_realloc realloc
|
#define mdbx_realloc realloc
|
||||||
#define mdbx_free free
|
#define mdbx_free free
|
||||||
|
#define mdbx_strdup strdup
|
||||||
#endif /* Platform */
|
#endif /* Platform */
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
@ -422,13 +423,9 @@ static __inline size_t mdbx_syspagesize(void) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline char *mdbx_strdup(const char *str) {
|
#ifndef mdbx_strdup
|
||||||
#ifdef _MSC_VER
|
char *mdbx_strdup(const char *str);
|
||||||
return _strdup(str);
|
|
||||||
#else
|
|
||||||
return strdup(str);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
static __inline int mdbx_get_errno(void) {
|
static __inline int mdbx_get_errno(void) {
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user