diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-03-20 03:15:03 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-03-20 23:00:09 +0100 |
commit | 9a17484d986f6cb8828afdf911db425b574c63fd (patch) | |
tree | 878d64b9079ae9dfd878be7362d58e49128db4cd /src/shared | |
parent | 5407f2dea3efa5234140f1adb9c2be9916d77cdc (diff) |
bus: implement demarshaller
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 19 | ||||
-rw-r--r-- | src/shared/util.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index f94abbcc02..69f1b00934 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -5797,3 +5797,22 @@ char *strextend(char **x, ...) { return r + l; } + +char *strrep(const char *s, unsigned n) { + size_t l; + char *r, *p; + unsigned i; + + assert(s); + + l = strlen(s); + p = r = malloc(l * n + 1); + if (!r) + return NULL; + + for (i = 0; i < n; i++) + p = stpcpy(p, s); + + *p = 0; + return r; +} diff --git a/src/shared/util.h b/src/shared/util.h index 25c00843ec..f75c66bb83 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -608,3 +608,4 @@ static inline void *mempset(void *s, int c, size_t n) { char *hexmem(const void *p, size_t l); char *strextend(char **x, ...); +char *strrep(const char *s, unsigned n); |