OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_1_x/] [or1ksim/] [port/] [strndup.c] - Rev 1771

Go to most recent revision | 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
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.