mirror of
https://gitea.invidious.io/iv-org/litespeed-quic.git
synced 2024-08-15 00:53:43 +00:00
Fix Windows build: implement own strndup(3)
This commit is contained in:
parent
ef3958b8fb
commit
a500a209cf
2 changed files with 27 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
@ -313,3 +314,23 @@ lsquic_sockaddr2str (const struct sockaddr *addr, char *buf, size_t sz)
|
||||||
if (len < (int) sz)
|
if (len < (int) sz)
|
||||||
snprintf(buf + len, sz - (size_t) len, ":%hu", port);
|
snprintf(buf + len, sz - (size_t) len, ":%hu", port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
char *
|
||||||
|
lsquic_strndup (const char *s, size_t n)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *copy;
|
||||||
|
|
||||||
|
len = strnlen(s, n);
|
||||||
|
copy = malloc(n + 1);
|
||||||
|
if (copy)
|
||||||
|
{
|
||||||
|
memcpy(copy, s, len);
|
||||||
|
copy[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -49,6 +49,12 @@ lsquic_sockaddr2str (const struct sockaddr *addr, char *buf, size_t sz);
|
||||||
|
|
||||||
#define SA2STR(sa_, buf_) (lsquic_sockaddr2str(sa_, buf_, sizeof(buf_)), buf_)
|
#define SA2STR(sa_, buf_) (lsquic_sockaddr2str(sa_, buf_, sizeof(buf_)), buf_)
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
char *
|
||||||
|
lsquic_strndup(const char *s, size_t n);
|
||||||
|
#define strndup lsquic_strndup
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue