From a2142e884b9090f5b5f42b55381a1f848c2426bb Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Jun 2020 21:25:17 +0200 Subject: shared: add nm_str_buf_append_c_repeated() helper --- shared/nm-glib-aux/nm-str-buf.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/shared/nm-glib-aux/nm-str-buf.h b/shared/nm-glib-aux/nm-str-buf.h index b582e2c8a6..13af81c01d 100644 --- a/shared/nm-glib-aux/nm-str-buf.h +++ b/shared/nm-glib-aux/nm-str-buf.h @@ -166,6 +166,19 @@ nm_str_buf_erase (NMStrBuf *strbuf, /*****************************************************************************/ +static inline void +nm_str_buf_append_c_repeated (NMStrBuf *strbuf, + char ch, + guint len) +{ + if (len > 0) { + nm_str_buf_maybe_expand (strbuf, len + 1, FALSE); + do { + strbuf->_priv_str[strbuf->_priv_len++] = ch; + } while (--len > 0); + } +} + static inline void nm_str_buf_append_c (NMStrBuf *strbuf, char ch) -- cgit v1.2.1