aboutsummaryrefslogtreecommitdiff
path: root/src/common/libc
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-24 16:09:04 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-24 16:09:04 +0100
commitf2c07854463763ed82e00857ae6d9bcbc924e42c (patch)
treeddeac108511835400cfba6525f7e9ca865afb1e4 /src/common/libc
parent7e908dabaaf6c67ef5000406a0bb3a6a29beca01 (diff)
downloadkogata-f2c07854463763ed82e00857ae6d9bcbc924e42c.tar.gz
kogata-f2c07854463763ed82e00857ae6d9bcbc924e42c.zip
Make way for ISO 9660 driver.
Diffstat (limited to 'src/common/libc')
-rw-r--r--src/common/libc/string.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/libc/string.c b/src/common/libc/string.c
index dfc93e6..e5f7a53 100644
--- a/src/common/libc/string.c
+++ b/src/common/libc/string.c
@@ -114,7 +114,7 @@ void *memset(void *dest, int val, size_t count) {
}
char *strdup(const char* str) {
- int len = strlen(str) + 1;
+ size_t len = strlen(str) + 1;
char* ret = (char*)malloc(len);
if (ret == 0) return 0;
@@ -123,4 +123,16 @@ char *strdup(const char* str) {
return ret;
}
+char *strndup(const char* str, size_t count) {
+ size_t len = strlen(str);
+ if (count < len) len = count;
+
+ char* ret = (char*)malloc(len + 1);
+ if (ret == 0) return 0;
+
+ memcpy(ret, str, len);
+ ret[len] = 0;
+ return ret;
+}
+
/* vim: set ts=4 sw=4 tw=0 noet :*/