Adding upstream version 4.00~pre54+dfsg.
[syslinux-debian/hramrach.git] / com32 / lib / strndup.c
blobd1073a8c89e2d70d8227d128e3415ccf07f283ac
1 /*
2 * strndup.c
3 */
5 #include <string.h>
6 #include <stdlib.h>
8 char *strndup(const char *s, size_t n)
10 int l = n > strlen(s) ? strlen(s) + 1 : n + 1;
11 char *d = malloc(l);
13 if (d)
14 memcpy(d, s, l);
15 d[n] = '\0';
16 return d;