ADd strlcpy when necessary.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
c165ae4838
commit
200d59f91b
1 changed files with 19 additions and 0 deletions
19
src/compat.h
19
src/compat.h
|
|
@ -47,4 +47,23 @@
|
|||
static void f(void)
|
||||
#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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue