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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [port/] [strndup.c] - Blame information for rev 1350

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

Line No. Rev Author Line
1 1350 nogj
 
2
#include "config.h"
3
#include "port.h"
4
 
5
#include <string.h>
6
 
7
#if !defined(HAVE_STRNDUP)
8
 
9
/* Taken from glibc */
10
char *
11
strndup (const char *s, size_t n)
12
{
13
        char *new;
14
        size_t len = strlen (s);
15
        if (len>n)
16
                len=n;
17
 
18
        new = (char *) malloc (len + 1);
19
 
20
        if (new == NULL)
21
                return NULL;
22
 
23
        new[len] = '\0';
24
        return (char *) memcpy (new, s, len);
25
}
26
 
27
#endif

powered by: WebSVN 2.1.0

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