diff options
author | Thomas Haller <thaller@redhat.com> | 2018-09-09 16:28:13 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-04-03 11:31:12 +0200 |
commit | 686b58571b4adab222ff7e49647027ef5f17315c (patch) | |
tree | 3bfa53d23205e5667988f70404c063f916fc87f5 | |
parent | beec47e70a7180f3e03556724ae7d1f67c016e8a (diff) | |
download | NetworkManager-686b58571b4adab222ff7e49647027ef5f17315c.tar.gz |
shared: use NMStrBuf for implementing nm_utils_str_utf8safe_unescape()
-rw-r--r-- | shared/nm-glib-aux/nm-shared-utils.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c index e941232a82..14e32956db 100644 --- a/shared/nm-glib-aux/nm-shared-utils.c +++ b/shared/nm-glib-aux/nm-shared-utils.c @@ -2217,7 +2217,7 @@ _str_buf_append_c_escape_octal (NMStrBuf *strbuf, gconstpointer nm_utils_buf_utf8safe_unescape (const char *str, gsize *out_len, gpointer *to_free) { - GString *gstr; + NMStrBuf strbuf; gsize len; const char *s; @@ -2239,9 +2239,9 @@ nm_utils_buf_utf8safe_unescape (const char *str, gsize *out_len, gpointer *to_fr return str; } - gstr = g_string_new_len (NULL, len); + nm_str_buf_init (&strbuf, len, FALSE); - g_string_append_len (gstr, str, s - str); + nm_str_buf_append_len (&strbuf, str, s - str); str = s; for (;;) { @@ -2288,21 +2288,20 @@ nm_utils_buf_utf8safe_unescape (const char *str, gsize *out_len, gpointer *to_fr str++; } - g_string_append_c (gstr, ch); + nm_str_buf_append_c (&strbuf, ch); s = strchr (str, '\\'); if (!s) { - g_string_append (gstr, str); + nm_str_buf_append (&strbuf, str); break; } - g_string_append_len (gstr, str, s - str); + nm_str_buf_append_len (&strbuf, str, s - str); str = s; } - *out_len = gstr->len; - *to_free = gstr->str; - return g_string_free (gstr, FALSE); + return (*to_free = nm_str_buf_finalize (&strbuf, + out_len)); } /** |