summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared/nm-keyfile/nm-keyfile-utils.c13
-rw-r--r--shared/nm-keyfile/nm-keyfile-utils.h11
2 files changed, 9 insertions, 15 deletions
diff --git a/shared/nm-keyfile/nm-keyfile-utils.c b/shared/nm-keyfile/nm-keyfile-utils.c
index 6356f8c444..627f529978 100644
--- a/shared/nm-keyfile/nm-keyfile-utils.c
+++ b/shared/nm-keyfile/nm-keyfile-utils.c
@@ -9,6 +9,8 @@
#include <stdlib.h>
+#include "nm-glib-aux/nm-str-buf.h"
+
#include "nm-keyfile-internal.h"
#include "nm-setting-wired.h"
#include "nm-setting-wireless.h"
@@ -158,21 +160,18 @@ nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
const guint8 *data,
gsize length)
{
+ nm_auto_str_buf NMStrBuf strbuf = { };
gsize i;
- gsize l = length * 4 + 2;
- gs_free char *value = g_malloc (l);
- char *s = value;
g_return_if_fail (kf);
g_return_if_fail (!length || data);
g_return_if_fail (group && group[0]);
g_return_if_fail (key && key[0]);
- value[0] = '\0';
+ nm_str_buf_init (&strbuf, length * 4u + 2u, FALSE);
for (i = 0; i < length; i++)
- nm_utils_strbuf_append (&s, &l, "%d;", (int) data[i]);
- nm_assert (l > 0);
- nm_keyfile_plugin_kf_set_value (kf, group, key, value);
+ nm_str_buf_append_printf (&strbuf, "%u;", (guint) data[i]);
+ nm_keyfile_plugin_kf_set_value (kf, group, key, nm_str_buf_get_str (&strbuf));
}
#define DEFINE_KF_WRAPPER_GET(fcn_name, get_ctype, key_file_get_fcn) \
diff --git a/shared/nm-keyfile/nm-keyfile-utils.h b/shared/nm-keyfile/nm-keyfile-utils.h
index 98b0129a59..719c32c2fc 100644
--- a/shared/nm-keyfile/nm-keyfile-utils.h
+++ b/shared/nm-keyfile/nm-keyfile-utils.h
@@ -19,20 +19,15 @@ const char *nm_keyfile_plugin_get_setting_name_for_alias (const char *alias);
/*****************************************************************************/
-void nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf,
- const char *group,
- const char *key,
- const guint8 *list,
- gsize length);
-
int *nm_keyfile_plugin_kf_get_integer_list (GKeyFile *kf, const char *group, const char *key, gsize *out_length, GError **error);
char **nm_keyfile_plugin_kf_get_string_list (GKeyFile *kf, const char *group, const char *key, gsize *out_length, GError **error);
char *nm_keyfile_plugin_kf_get_string (GKeyFile *kf, const char *group, const char *key, GError **error);
gboolean nm_keyfile_plugin_kf_get_boolean (GKeyFile *kf, const char *group, const char *key, GError **error);
char *nm_keyfile_plugin_kf_get_value (GKeyFile *kf, const char *group, const char *key, GError **error);
-void nm_keyfile_plugin_kf_set_integer_list (GKeyFile *kf, const char *group, const char *key, int *list, gsize length);
-void nm_keyfile_plugin_kf_set_string_list (GKeyFile *kf, const char *group, const char *key, const char *const*list, gsize length);
+void nm_keyfile_plugin_kf_set_integer_list_uint8 (GKeyFile *kf, const char *group, const char *key, const guint8 *list, gsize length);
+void nm_keyfile_plugin_kf_set_integer_list (GKeyFile *kf, const char *group, const char *key, int *list, gsize length);
+void nm_keyfile_plugin_kf_set_string_list (GKeyFile *kf, const char *group, const char *key, const char *const*list, gsize length);
void nm_keyfile_plugin_kf_set_string (GKeyFile *kf, const char *group, const char *key, const char *value);
void nm_keyfile_plugin_kf_set_boolean (GKeyFile *kf, const char *group, const char *key, gboolean value);