OLD | NEW |
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include <string.h> | 2 #include <string.h> |
3 #include "libc.h" | 3 #include "libc.h" |
4 | 4 |
5 char *__strdup(const char *s) | 5 char* __strdup(const char* s) { |
6 { | 6 size_t l = strlen(s); |
7 » size_t l = strlen(s); | 7 char* d = malloc(l + 1); |
8 » char *d = malloc(l+1); | 8 if (!d) |
9 » if (!d) return NULL; | 9 return NULL; |
10 » return memcpy(d, s, l+1); | 10 return memcpy(d, s, l + 1); |
11 } | 11 } |
12 | 12 |
13 weak_alias(__strdup, strdup); | 13 weak_alias(__strdup, strdup); |
OLD | NEW |