URL
https://opencores.org/ocsvn/or1k_old/or1k_old/trunk
Subversion Repositories or1k_old
[/] [or1k_old/] [tags/] [stable_0_2_0_rc3/] [or1ksim/] [port/] [strndup.c] - Rev 1782
Compare with Previous | Blame | View Log
#include "config.h" #include "port.h" #include <string.h> #if !defined(HAVE_STRNDUP) /* Taken from glibc */ char * strndup (const char *s, size_t n) { char *new; size_t len = strlen (s); if (len>n) len=n; new = (char *) malloc (len + 1); if (new == NULL) return NULL; new[len] = '\0'; return (char *) memcpy (new, s, len); } #endif