fio: ioengine flag cleanup
[fio.git] / oslib / strndup.c
1 #ifndef CONFIG_HAVE_STRNDUP
2
3 #include <stdlib.h>
4 #include <string.h>
5 #include "strndup.h"
6
7 char *strndup(const char *s, size_t n)
8 {
9         char *str = malloc(n + 1);
10
11         if (str) {
12                 strncpy(str, s, n);
13                 str[n] = '\0';
14         }
15
16         return str;
17 }
18
19 #endif