URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 1419 |
Rev 1765 |
|
|
#include "config.h"
|
#include "config.h"
|
#include "port.h"
|
#include "port.h"
|
|
|
#include <string.h>
|
#include <string.h>
|
|
|
#if !defined(HAVE_STRNDUP)
|
#if !defined(HAVE_STRNDUP)
|
|
|
/* Taken from glibc */
|
/* Taken from glibc */
|
char *
|
char *
|
strndup (const char *s, size_t n)
|
strndup (const char *s, size_t n)
|
{
|
{
|
char *new;
|
char *new;
|
size_t len = strlen (s);
|
size_t len = strlen (s);
|
if (len>n)
|
if (len>n)
|
len=n;
|
len=n;
|
|
|
new = (char *) malloc (len + 1);
|
new = (char *) malloc (len + 1);
|
|
|
if (new == NULL)
|
if (new == NULL)
|
return NULL;
|
return NULL;
|
|
|
new[len] = '\0';
|
new[len] = '\0';
|
return (char *) memcpy (new, s, len);
|
return (char *) memcpy (new, s, len);
|
}
|
}
|
|
|
#endif
|
#endif
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.