repo.or.cz
/
syslinux-debian
/
hramrach.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Adding upstream version 3.61.
[syslinux-debian/hramrach.git]
/
com32
/
lib
/
strndup.c
blob
1b44e6f99ae697b201373e84cdc0a0372103dc7a
1
/*
2
* strndup.c
3
*/
4
5
#include <string.h>
6
#include <stdlib.h>
7
8
char
*
strndup
(
const char
*
s
,
size_t
n
)
9
{
10
int
l
=
n
>
strlen
(
s
) ?
strlen
(
s
)+
1
:
n
+
1
;
11
char
*
d
=
malloc
(
l
);
12
13
if
(
d
)
14
memcpy
(
d
,
s
,
l
);
15
d
[
n
] =
'\0'
;
16
return
d
;
17
}