summaryrefslogtreecommitdiff
path: root/lib/strndup.c
blob: 0f5e4142c47ea2e5721215897c8269914bcaac5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "config.h"

#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif

#include <string.h>

char *_xine_private_strndup(const char *s, size_t n) {
  char *ret;
  
  ret = malloc (n + 1);
  strncpy(ret, s, n);
  ret[n] = '\0';
  return ret;
}