[telepathy-glib/master] _tp_quark_array_copy(): copy a 0-terminated GQuark array into a GArray.

David Laban david.laban at collabora.co.uk
Tue Nov 17 08:31:38 PST 2009


This is a helper function for Account, as will be seen in the next commit.
---
 telepathy-glib/util-internal.h |   28 ++++++++++++++++++++++++++++
 telepathy-glib/util.c          |   24 ++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100644 telepathy-glib/util-internal.h

diff --git a/telepathy-glib/util-internal.h b/telepathy-glib/util-internal.h
new file mode 100644
index 0000000..30ba017
--- /dev/null
+++ b/telepathy-glib/util-internal.h
@@ -0,0 +1,28 @@
+/*
+ * util-internal.h - Headers for non-public telepathy-glib utility functions
+ *
+ * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef __TP_UTIL_INTERNAL_H__
+#define __TP_UTIL_INTERNAL_H__
+
+#include <glib.h>
+
+GArray *_tp_quark_array_copy (const GQuark *quarks);
+
+#endif /* __TP_UTIL_INTERNAL_H__ */
\ No newline at end of file
diff --git a/telepathy-glib/util.c b/telepathy-glib/util.c
index 306f929..4e976e3 100644
--- a/telepathy-glib/util.c
+++ b/telepathy-glib/util.c
@@ -28,6 +28,7 @@
  * GLib, but aren't.
  */
 
+#include <telepathy-glib/util-internal.h>
 #include <telepathy-glib/util.h>
 
 #include <string.h>
@@ -808,3 +809,26 @@ tp_g_key_file_get_uint64 (GKeyFile *key_file,
   g_free (s);
   return v;
 }
+
+/**
+ * _tp_quark_array_copy:
+ * @quarks: A 0-terminated list of quarks to copy
+ *
+ * Returns: A new GArray containing a copy of @quarks.
+ * Be sure to unref it when finished.
+ */
+GArray *
+_tp_quark_array_copy (const GQuark *quarks)
+{
+  GArray *array;
+  const GQuark *q;
+
+  array = g_array_new (TRUE, TRUE, sizeof (GQuark));
+
+  for (q = quarks; q != NULL && *q != 0; q++)
+    {
+      g_array_append_val (array, *q);
+    }
+
+  return array;
+}
\ No newline at end of file
-- 
1.5.6.5




More information about the telepathy-commits mailing list