summaryrefslogtreecommitdiff
path: root/garray.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@gtk.org>1998-11-23 15:02:44 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-11-23 15:02:44 +0000
commiteabb208b306f159264ed14d0362b56b7749a70e2 (patch)
tree9aef7e7ba3e4ff43904e10debd8a52470869dce6 /garray.c
parent70a6dbff8767b9a836e6d62411d5d4450cc884fc (diff)
added g_array_insert_vals() to insert elements at an arbitrary index, and
Mon Nov 23 10:03:58 1998 Owen Taylor <otaylor@gtk.org> * glib.h garray.[ch]: added g_array_insert_vals() to insert elements at an arbitrary index, and g_array_insert_val() macro.
Diffstat (limited to 'garray.c')
-rw-r--r--garray.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/garray.c b/garray.c
index fd5e7b9e2..0247972ec 100644
--- a/garray.c
+++ b/garray.c
@@ -113,6 +113,27 @@ g_array_prepend_vals (GArray *farray,
}
GArray*
+g_array_insert_vals (GArray *farray,
+ guint index,
+ gconstpointer data,
+ guint len)
+{
+ GRealArray *array = (GRealArray*) farray;
+
+ g_array_maybe_expand (array, len);
+
+ g_memmove (array->data + array->elt_size * (len + index),
+ array->data + array->elt_size * index,
+ array->elt_size * (array->len - index));
+
+ memcpy (array->data + array->elt_size * index, data, len * array->elt_size);
+
+ array->len += len;
+
+ return farray;
+}
+
+GArray*
g_array_set_size (GArray *farray,
guint length)
{