summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
committerLennart Poettering <lennart@poettering.net>2015-02-03 02:05:59 +0100
commit63c372cb9df3bee01e3bf8cd7f96f336bddda846 (patch)
treebf4d1b6e41f72927a2b58e7dd21daa0c496aaa96 /src/shared/util.h
parent44de0efc6e406515fc1cf8b95d9655d0d7f7ffff (diff)
util: rework strappenda(), and rename it strjoina()
After all it is now much more like strjoin() than strappend(). At the same time, add support for NULL sentinels, even if they are normally not necessary.
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index 410ce65f14..7dfabbc07d 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -931,19 +931,19 @@ int unlink_noerrno(const char *path);
(void*)memset(_new_, 0, _size_); \
})
-#define strappenda(a, ...) \
- ({ \
- int _len = strlen(a); \
- unsigned _i; \
- char *_d_, *_p_; \
- const char *_appendees_[] = { __VA_ARGS__ }; \
- for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
- _len += strlen(_appendees_[_i]); \
- _d_ = alloca(_len + 1); \
- _p_ = stpcpy(_d_, a); \
- for (_i = 0; _i < ELEMENTSOF(_appendees_); _i++) \
- _p_ = stpcpy(_p_, _appendees_[_i]); \
- _d_; \
+#define strjoina(a, ...) \
+ ({ \
+ const char *_appendees_[] = { a, __VA_ARGS__ }; \
+ char *_d_, *_p_; \
+ int _len_ = 0; \
+ unsigned _i_; \
+ for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+ _len_ += strlen(_appendees_[_i_]); \
+ _p_ = _d_ = alloca(_len_ + 1); \
+ for (_i_ = 0; _i_ < ELEMENTSOF(_appendees_) && _appendees_[_i_]; _i_++) \
+ _p_ = stpcpy(_p_, _appendees_[_i_]); \
+ *_p_ = 0; \
+ _d_; \
})
#define procfs_file_alloca(pid, field) \