http://git.etherboot.org
/
people
/
xl0
/
gpxe.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6b6dbe5
)
move strndup back to string.c - used by strdup
author
Holger Lubitz
<hal@duncan.ol.sub.de>
Wed, 1 Aug 2007 23:48:20 +0000
(
01:48
+0200)
committer
Holger Lubitz
<hal@duncan.ol.sub.de>
Wed, 1 Aug 2007 23:48:20 +0000
(
01:48
+0200)
src/core/string.c
patch
|
blob
|
history
diff --git
a/src/core/string.c
b/src/core/string.c
index
8577215
..
2e17bdc
100644
(file)
--- a/
src/core/string.c
+++ b/
src/core/string.c
@@
-333,6
+333,21
@@
void * memchr(const void *s, int c, size_t n)
#endif
+char * strndup(const char *s, size_t n)
+{
+ size_t len = strlen(s);
+ char *new;
+
+ if (len>n)
+ len = n;
+ new = malloc(len+1);
+ if (new) {
+ new[len] = '\0';
+ memcpy(new,s,len);
+ }
+ return new;
+}
+
char * strdup(const char *s) {
return strndup(s, ~((size_t)0));
}