| 38 | #include <sys/malloc.h> |
| 39 | |
| 40 | char * |
| 41 | strndup(const char *string, size_t maxlen, struct malloc_type *type) |
| 42 | { |
| 43 | size_t len; |
| 44 | char *copy; |
| 45 | |
| 46 | len = strnlen(string, maxlen) + 1; |
| 47 | copy = malloc(len, type, M_WAITOK); |
| 48 | bcopy(string, copy, len); |
| 49 | copy[len - 1] = '\0'; |
| 50 | return (copy); |
| 51 | } |