Add replacement for strndup(). MinGW doesn't have it. From Pete Batard again.
This commit is contained in:
@@ -59,6 +59,21 @@
|
||||
# define CharNext(p) ((p) + 1)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRNDUP
|
||||
static inline char *strndup(const char *s, size_t n)
|
||||
{
|
||||
char *result;
|
||||
size_t len = strlen (s);
|
||||
if (n < len)
|
||||
len = n;
|
||||
result = (char *) malloc (len + 1);
|
||||
if (!result)
|
||||
return 0;
|
||||
result[len] = '\0';
|
||||
return (char *) strncpy (result, s, len);
|
||||
}
|
||||
#endif /*HAVE_STRNDUP*/
|
||||
|
||||
static char *
|
||||
strrdirsep(const char *path)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user