mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-06-19 12:28:29 +02:00
shared: add nm_str_buf_append0() and nm_str_buf_append_len0() helper
These are basically nm_str_buf_append()/nm_str_buf_append_len() and nm_str_buf_get_str() in one.
This commit is contained in:
parent
506f95ecaf
commit
d53abfd989
1 changed files with 28 additions and 0 deletions
|
|
@ -225,6 +225,25 @@ nm_str_buf_append_len (NMStrBuf *strbuf,
|
|||
}
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_str_buf_append_len0 (NMStrBuf *strbuf,
|
||||
const char *str,
|
||||
gsize len)
|
||||
{
|
||||
_nm_str_buf_assert (strbuf);
|
||||
|
||||
/* this is basically like nm_str_buf_append_len() and
|
||||
* nm_str_buf_get_str() in one. */
|
||||
|
||||
nm_str_buf_maybe_expand (strbuf, len + 1u, FALSE);
|
||||
if (len > 0) {
|
||||
memcpy (&strbuf->_priv_str[strbuf->_priv_len], str, len);
|
||||
strbuf->_priv_len += len;
|
||||
}
|
||||
strbuf->_priv_str[strbuf->_priv_len] = '\0';
|
||||
return strbuf->_priv_str;
|
||||
}
|
||||
|
||||
static inline void
|
||||
nm_str_buf_append (NMStrBuf *strbuf,
|
||||
const char *str)
|
||||
|
|
@ -234,6 +253,15 @@ nm_str_buf_append (NMStrBuf *strbuf,
|
|||
nm_str_buf_append_len (strbuf, str, strlen (str));
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_str_buf_append0 (NMStrBuf *strbuf,
|
||||
const char *str)
|
||||
{
|
||||
nm_assert (str);
|
||||
|
||||
return nm_str_buf_append_len0 (strbuf, str, strlen (str));
|
||||
}
|
||||
|
||||
void nm_str_buf_append_printf (NMStrBuf *strbuf,
|
||||
const char *format,
|
||||
...) _nm_printf (2, 3);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue