Refactor #includes and headers
[fio.git] / oslib / strndup.c
CommitLineData
b29c71c4 1#include <stdlib.h>
3d2d14bc 2
df27f9ac 3#include "strndup.h"
b29c71c4
JA
4
5#ifndef CONFIG_HAVE_STRNDUP
6
7char *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