diff mbox

[1/4,V2] Utility function strpadcpy() added

Message ID 1332062674-14186-2-git-send-email-dmitry.fleytman@ravellosystems.com
State New
Headers show

Commit Message

Dmitry Fleytman March 18, 2012, 9:24 a.m. UTC
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Yan Vugenfirer <yan@daynix.com>
---
 cutils.c      |    7 +++++++
 qemu-common.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/cutils.c b/cutils.c
index af308cd..3ccf45c 100644
--- a/cutils.c
+++ b/cutils.c
@@ -27,6 +27,13 @@ 
 
 #include "qemu_socket.h"
 
+void strpadcpy(char *buf, int buf_size, const char *str, char pad)
+{
+    int len = qemu_strnlen(str, buf_size);
+    memcpy(buf, str, len);
+    memset(buf + len, pad, buf_size - len);
+}
+
 void pstrcpy(char *buf, int buf_size, const char *str)
 {
     int c;
diff --git a/qemu-common.h b/qemu-common.h
index b0fdf5c..fdd3d17 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -134,6 +134,7 @@  int qemu_timedate_diff(struct tm *tm);
 
 /* cutils.c */
 void pstrcpy(char *buf, int buf_size, const char *str);
+void strpadcpy(char *buf, int buf_size, const char *str, char pad);
 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);