Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/klibc/strndup.c

Source at commit 1295 created 12 years 8 months ago.
By meklort, Remove libsaio.h from klibc
1/*
2 * strndup.c
3 */
4
5#include <stdlib.h>
6#include <string.h>
7
8char *strndup(const char *s, size_t n)
9{
10int l = n > strlen(s) ? strlen(s) + 1 : n + 1;
11char *d = malloc(l);
12
13if (d)
14memcpy(d, s, l);
15d[n] = '\0';
16return d;
17}
18

Archive Download this file

Revision: 1295