diff options
author | Thomas Haller <thaller@redhat.com> | 2020-04-06 10:44:42 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-09 21:51:06 +0200 |
commit | 01033aec569b829225361d4f07bc7e3fdbcdddfd (patch) | |
tree | 7acfd910fefee1f151861df7477a9d6bcc3cb5cd | |
parent | 4d4c85ece62f16c95019e692b22b269f50c736be (diff) | |
download | NetworkManager-01033aec569b829225361d4f07bc7e3fdbcdddfd.tar.gz |
shared/strbuf: add nm_str_buf_ensure_trailing_c() helper function
-rw-r--r-- | shared/nm-glib-aux/nm-str-buf.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-str-buf.h b/shared/nm-glib-aux/nm-str-buf.h index 564f91c4b5..5701fcdee2 100644 --- a/shared/nm-glib-aux/nm-str-buf.h +++ b/shared/nm-glib-aux/nm-str-buf.h @@ -129,6 +129,16 @@ void nm_str_buf_append_printf (NMStrBuf *strbuf, const char *format, ...) _nm_printf (2, 3); +static inline void +nm_str_buf_ensure_trailing_c (NMStrBuf *strbuf, char ch) +{ + _nm_str_buf_assert (strbuf); + + if ( strbuf->len == 0 + || strbuf->_str[strbuf->len - 1] != ch) + nm_str_buf_append_c (strbuf, ch); +} + /*****************************************************************************/ /** |