summaryrefslogtreecommitdiff
path: root/cutils.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-25 11:23:27 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-10-25 11:23:27 +0000
commit11acb1be910a8b9cfa32f8c39bbed6239198e7ac (patch)
treeb3626dc8891c995c03cd6c33b5a3c3bd44e9c28e /cutils.c
parent7f06a51d23c4ec1f9f790c3dc12019b6bf4c61a9 (diff)
downloadqemu-11acb1be910a8b9cfa32f8c39bbed6239198e7ac.tar.gz
qemu-11acb1be910a8b9cfa32f8c39bbed6239198e7ac.tar.bz2
qemu-11acb1be910a8b9cfa32f8c39bbed6239198e7ac.zip
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
Diffstat (limited to 'cutils.c')
-rw-r--r--cutils.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/cutils.c b/cutils.c
index 9ef2fa627c..8fcb62efed 100644
--- a/cutils.c
+++ b/cutils.c
@@ -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;