wmii/lib/libstuff/util/estrndup.c
2010-06-14 10:30:23 -04:00

16 lines
281 B
C

/* Written by Kris Maglione <maglione.k at Gmail> */
/* Public domain */
#include <string.h>
#include "util.h"
char*
estrndup(const char *str, uint len) {
char *ret;
len = min(len, strlen(str));
ret = emalloc(len + 1);
memcpy(ret, str, len);
ret[len] = '\0';
return ret;
}