[anjuta/sdb-core-trans: 57/59] libanjuta: added an util function to clone GPtrArrays.
- From: Massimo Cora' <mcora src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta/sdb-core-trans: 57/59] libanjuta: added an util function to clone GPtrArrays.
- Date: Fri, 30 Jul 2010 00:05:07 +0000 (UTC)
commit 9f57d6e6c424a0fc3877d2d7eac875bcc6c832db
Author: Massimo Corà <mcora src gnome org>
Date: Fri Jul 30 00:10:48 2010 +0200
libanjuta: added an util function to clone GPtrArrays.
libanjuta/anjuta-utils.c | 29 +++++++++++++++++++++++++++++
libanjuta/anjuta-utils.h | 1 +
2 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/libanjuta/anjuta-utils.c b/libanjuta/anjuta-utils.c
index f471568..d345297 100644
--- a/libanjuta/anjuta-utils.c
+++ b/libanjuta/anjuta-utils.c
@@ -2423,3 +2423,32 @@ anjuta_utils_drop_get_files (GtkSelectionData *selection_data)
return files;
}
+
+/**
+ * anjuta_utils_clone_string_gptrarray:
+ * @source: The source GPtrArray containing items representing strings
+ *
+ * Clones the contents of source GPtrArray into a new allocated GPtrArray.
+ *
+ * Return a new allocated GPtrArray with strings g_strdup (), NULL on error.
+ * The returned array has set g_free as GDestroyNotity function, so that user
+ * should only care to g_ptr_array_unref () without freeing the strings.
+ */
+GPtrArray *
+anjuta_util_clone_string_gptrarray (const GPtrArray* source)
+{
+ gint i;
+ GPtrArray *dest;
+
+ g_return_val_if_fail (source != NULL, NULL);
+
+ dest = g_ptr_array_sized_new (source->len);
+ g_ptr_array_set_free_func (dest, g_free);
+
+ for (i = 0; i < source->len; i++)
+ {
+ g_ptr_array_add (dest, g_strdup (g_ptr_array_index (source, i)));
+ }
+
+ return dest;
+}
diff --git a/libanjuta/anjuta-utils.h b/libanjuta/anjuta-utils.h
index b091494..a2ed19a 100644
--- a/libanjuta/anjuta-utils.h
+++ b/libanjuta/anjuta-utils.h
@@ -149,6 +149,7 @@ gboolean anjuta_util_builder_get_objects (GtkBuilder *builder, const gchar *firs
/* Helper for drag and drop */
GSList *anjuta_utils_drop_get_files (GtkSelectionData *selection_data);
+GPtrArray *anjuta_util_clone_string_gptrarray (const GPtrArray* source);
/* Temporarily copied here */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]