qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 7/8] cutil: add strocat(), to concat a string to an of


From: Michael Roth
Subject: [Qemu-devel] [RFC 7/8] cutil: add strocat(), to concat a string to an offset in another
Date: Mon, 19 Sep 2011 09:41:48 -0500

Signed-off-by: Michael Roth <address@hidden>
---
 cutils.c      |    8 ++++++++
 qemu-common.h |    1 +
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/cutils.c b/cutils.c
index c91f887..0835834 100644
--- a/cutils.c
+++ b/cutils.c
@@ -84,6 +84,14 @@ int stristart(const char *str, const char *val, const char 
**ptr)
     return 1;
 }
 
+/* concat first 'offset' chars in 'dest' with 'src' */
+char *strocat(char *buf, const char *src, int offset)
+{
+    memcpy(&buf[offset], src, strlen(src));
+    buf[offset+strlen(src)] = '\0';
+    return buf;
+}
+
 /* XXX: use host strnlen if available ? */
 int qemu_strnlen(const char *s, int max_len)
 {
diff --git a/qemu-common.h b/qemu-common.h
index 404c421..0a9b919 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -138,6 +138,7 @@ void pstrcpy(char *buf, int buf_size, const char *str);
 char *pstrcat(char *buf, int buf_size, const char *s);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
+char *strocat(char *dest, const char *src, int offset);
 int qemu_strnlen(const char *s, int max_len);
 time_t mktimegm(struct tm *tm);
 int qemu_fls(int i);
-- 
1.7.0.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]