mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-08 07:03:35 +02:00
ADd strlcpy when necessary.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
19
src/compat.h
19
src/compat.h
@@ -47,4 +47,23 @@
|
|||||||
static void f(void)
|
static void f(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#ifndef HAVE_STRLCPY
|
||||||
|
static inline size_t strlcpy(char *dst, const char *src, size_t size)
|
||||||
|
{
|
||||||
|
size_t srclen = strlen(src);
|
||||||
|
|
||||||
|
if (size != 0) {
|
||||||
|
size_t copylen = (srclen >= size) ? size - 1 : srclen;
|
||||||
|
memcpy(dst, src, copylen);
|
||||||
|
dst[copylen] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return srclen;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // _COMPAT_H
|
#endif // _COMPAT_H
|
||||||
|
|||||||
Reference in New Issue
Block a user