diff options
author | Lai Jiangshan <laijs@cn.fujitsu.com> | 2011-12-12 15:15:52 +0800 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2015-06-01 16:39:49 +0100 |
commit | ec52d504239182f1a208bfc0000339a7601ae48e (patch) | |
tree | fa60319b251861a35defa4f88098f1bb8234e1cb /util | |
parent | 565a1509d7bd40ff46422c814ac4cc7d1a6347ea (diff) | |
download | kvmtool-ec52d504239182f1a208bfc0000339a7601ae48e.tar.gz |
kvm tools: move strlcat() to util/strbuf.c
strlcat() is a string related function.
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/strbuf.c | 26 | ||||
-rw-r--r-- | util/util.c | 25 |
2 files changed, 26 insertions, 25 deletions
diff --git a/util/strbuf.c b/util/strbuf.c index ec77ab1e..6632a144 100644 --- a/util/strbuf.c +++ b/util/strbuf.c @@ -1,5 +1,6 @@ /* user defined headers */ +#include <kvm/util.h> #include <kvm/strbuf.h> int prefixcmp(const char *str, const char *prefix) @@ -11,3 +12,28 @@ int prefixcmp(const char *str, const char *prefix) return (unsigned char)*prefix - (unsigned char)*str; } } + +/** + * strlcat - Append a length-limited, %NUL-terminated string to another + * @dest: The string to be appended to + * @src: The string to append to it + * @count: The size of the destination buffer. + */ +size_t strlcat(char *dest, const char *src, size_t count) +{ + size_t dsize = strlen(dest); + size_t len = strlen(src); + size_t res = dsize + len; + + DIE_IF(dsize >= count); + + dest += dsize; + count -= dsize; + if (len >= count) + len = count - 1; + + memcpy(dest, src, len); + dest[len] = 0; + + return res; +} diff --git a/util/util.c b/util/util.c index 4efbce9e..682ed6c2 100644 --- a/util/util.c +++ b/util/util.c @@ -74,28 +74,3 @@ void die_perror(const char *s) perror(s); exit(1); } - -/** - * strlcat - Append a length-limited, %NUL-terminated string to another - * @dest: The string to be appended to - * @src: The string to append to it - * @count: The size of the destination buffer. - */ -size_t strlcat(char *dest, const char *src, size_t count) -{ - size_t dsize = strlen(dest); - size_t len = strlen(src); - size_t res = dsize + len; - - DIE_IF(dsize >= count); - - dest += dsize; - count -= dsize; - if (len >= count) - len = count - 1; - - memcpy(dest, src, len); - dest[len] = 0; - - return res; -} |