diff options
author | Thomas Haller <thaller@redhat.com> | 2016-02-26 17:02:11 +0100 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2016-02-29 17:46:41 +0100 |
commit | eb80f690981fe849c3bfc2477f1d3350b6e35f6d (patch) | |
tree | 7defd70b9923209c6cce7fa02ae032e5323fbecd /src/NetworkManagerUtils.h | |
parent | 7f43e0a7b3f0f95740a284c3965359932368cbd1 (diff) | |
download | NetworkManager-eb80f690981fe849c3bfc2477f1d3350b6e35f6d.tar.gz |
utils: add nm_utils_strbuf_init() macro
Diffstat (limited to 'src/NetworkManagerUtils.h')
-rw-r--r-- | src/NetworkManagerUtils.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/NetworkManagerUtils.h b/src/NetworkManagerUtils.h index 87c898771c..8ca50736df 100644 --- a/src/NetworkManagerUtils.h +++ b/src/NetworkManagerUtils.h @@ -301,6 +301,19 @@ fcn_name (lookup_type val) \ /*****************************************************************************/ +static inline void +_nm_utils_strbuf_init (char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len) +{ + NM_SET_OUT (p_buf_len, len); + NM_SET_OUT (p_buf_ptr, buf); + buf[0] = '\0'; +} + +#define nm_utils_strbuf_init(buf, p_buf_ptr, p_buf_len) \ + G_STMT_START { \ + G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) > sizeof (char *)); \ + _nm_utils_strbuf_init ((buf), sizeof (buf), (p_buf_ptr), (p_buf_len)); \ + } G_STMT_END void nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) __attribute__((__format__ (__printf__, 3, 4))); void nm_utils_strbuf_append_c (char **buf, gsize *len, char c); void nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str); |