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