Replace uses of strndup (a GNU extension) with Qemu pstrdup

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5532 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
blueswir1 2008-10-25 11:23:27 +00:00
parent be15b141e0
commit 2bd7318c1a
3 changed files with 14 additions and 1 deletions

View file

@ -50,6 +50,18 @@ char *pstrcat(char *buf, int buf_size, const char *s)
return buf;
}
/* strdup with a limit */
char *pstrdup(const char *str, size_t buf_size)
{
size_t len;
char *buf;
len = MIN(buf_size, strlen(str));
buf = qemu_malloc(len);
pstrcpy(buf, len, str);
return buf;
}
int strstart(const char *str, const char *val, const char **ptr)
{
const char *p, *q;