shared: add nm_str_buf_append_{dirty,c_len}() helpers

This commit is contained in:
Thomas Haller 2021-01-12 19:03:42 +01:00
parent cc8706f815
commit 5a213541ea
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -267,6 +267,31 @@ nm_str_buf_append_required_delimiter(NMStrBuf *strbuf, char delimiter)
return strbuf;
}
static inline void
nm_str_buf_append_dirty(NMStrBuf *strbuf, gsize len)
{
_nm_str_buf_assert(strbuf);
/* this append @len bytes to the buffer, but it does not
* initialize them! */
if (len > 0) {
nm_str_buf_maybe_expand(strbuf, len, FALSE);
strbuf->_priv_len += len;
}
}
static inline void
nm_str_buf_append_c_len(NMStrBuf *strbuf, char ch, gsize len)
{
_nm_str_buf_assert(strbuf);
if (len > 0) {
nm_str_buf_maybe_expand(strbuf, len, FALSE);
memset(&strbuf->_priv_str[strbuf->_priv_len], ch, len);
strbuf->_priv_len += len;
}
}
static inline void
nm_str_buf_reset(NMStrBuf *strbuf, const char *str)
{