Add copy of strndup() for Lenny.
This commit is contained in:
parent
c42612643a
commit
d97d1b72d7
18
wsproxy.c
18
wsproxy.c
|
|
@ -287,6 +287,22 @@ encode(int in, int out)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static char *
|
||||||
|
do_strndup(const char *str, size_t n)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *copy;
|
||||||
|
|
||||||
|
for (len = 0; len < n && str[len]; len++)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((copy = malloc(len + 1)) == NULL)
|
||||||
|
return (NULL);
|
||||||
|
memcpy(copy, str, len);
|
||||||
|
copy[len] = '\0';
|
||||||
|
return (copy);
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
parsestring(const char *in)
|
parsestring(const char *in)
|
||||||
{
|
{
|
||||||
|
|
@ -299,7 +315,7 @@ parsestring(const char *in)
|
||||||
len--;
|
len--;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
return (strndup(in, len));
|
return (do_strndup(in, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue