update_engine: Move glib related utils to glib_utils.h.
This patch move the remaining glib.h functions used from utils.h to
glib_utils.h.
BUG=chromium:499886
TEST=emerge-link update_engine
Change-Id: Ia727cf3d4ee29fb33fa4db500ca83ea37d23a335
Reviewed-on: https://chromium-review.googlesource.com/281446
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
diff --git a/glib_utils.cc b/glib_utils.cc
index 3371da4..625d8d1 100644
--- a/glib_utils.cc
+++ b/glib_utils.cc
@@ -24,5 +24,14 @@
return message;
}
+gchar** StringVectorToGStrv(const std::vector<string> &vec_str) {
+ GPtrArray *p = g_ptr_array_new();
+ for (const string& str : vec_str) {
+ g_ptr_array_add(p, g_strdup(str.c_str()));
+ }
+ g_ptr_array_add(p, nullptr);
+ return reinterpret_cast<gchar**>(g_ptr_array_free(p, FALSE));
+}
+
} // namespace utils
} // namespace chromeos_update_engine