Author: joncham
Date: 2007-10-31 14:04:26 -0500 (Wed, 31 Oct 2007)
New Revision: 88601
Modified:
trunk/mono/eglib/ChangeLog
trunk/mono/eglib/src/garray.c
trunk/mono/eglib/src/ghashtable.c
trunk/mono/eglib/src/glib.h
trunk/mono/eglib/src/gpath.c
Log:
2007-10-31 Jonathan Chambers <[EMAIL PROTECTED]>
* src/ghashtable.c: Add g_hash_table_foreach_steal.
* src/garray.c: Add g_array_remove_index_fast.
* src/gpath.c (g_path_is_absolute): Handle windows paths.
* src/glib.h: Add g_hash_table_foreach_steal and
g_array_remove_index_fast
Contribution is licensed as MIT/X11.
Modified: trunk/mono/eglib/ChangeLog
===================================================================
--- trunk/mono/eglib/ChangeLog 2007-10-31 18:50:00 UTC (rev 88600)
+++ trunk/mono/eglib/ChangeLog 2007-10-31 19:04:26 UTC (rev 88601)
@@ -1,3 +1,12 @@
+2007-10-31 Jonathan Chambers <[EMAIL PROTECTED]>
+
+ * src/ghashtable.c: Add g_hash_table_foreach_steal.
+ * src/garray.c: Add g_array_remove_index_fast.
+ * src/gpath.c (g_path_is_absolute): Handle windows paths.
+ * src/glib.h: Add g_hash_table_foreach_steal and
g_array_remove_index_fast
+
+ Contribution is licensed as MIT/X11.
+
2007-06-13 Jonathan Chambers <[EMAIL PROTECTED]>
* src/gunicode.c: Add g_unichar_isxdigit and g_unichar_xdigit_value.
Modified: trunk/mono/eglib/src/garray.c
===================================================================
--- trunk/mono/eglib/src/garray.c 2007-10-31 18:50:00 UTC (rev 88600)
+++ trunk/mono/eglib/src/garray.c 2007-10-31 19:04:26 UTC (rev 88601)
@@ -181,3 +181,26 @@
return array;
}
+GArray*
+g_array_remove_index_fast (GArray *array,
+ guint index_)
+{
+ GArrayPriv *priv = (GArrayPriv*)array;
+
+ g_return_val_if_fail (array != NULL, NULL);
+
+ memmove (element_offset (priv, index_),
+ element_offset (priv, array->len - 1),
+ element_length (priv, array->len - index_));
+
+ array->len --;
+
+ if (priv->zero_terminated) {
+ memset (element_offset (priv, priv->array.len),
+ 0,
+ priv->element_size);
+ }
+
+ return array;
+}
+
Modified: trunk/mono/eglib/src/ghashtable.c
===================================================================
--- trunk/mono/eglib/src/ghashtable.c 2007-10-31 18:50:00 UTC (rev 88600)
+++ trunk/mono/eglib/src/ghashtable.c 2007-10-31 19:04:26 UTC (rev 88601)
@@ -358,6 +358,45 @@
return count;
}
+guint
+g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data)
+{
+ int i;
+ int count = 0;
+
+ g_return_val_if_fail (hash != NULL, 0);
+ g_return_val_if_fail (func != NULL, 0);
+
+ for (i = 0; i < hash->table_size; i++){
+ Slot *s, *last;
+
+ last = NULL;
+ for (s = hash->table [i]; s != NULL; ){
+ if ((*func)(s->key, s->value, user_data)){
+ Slot *n;
+
+ if (last == NULL){
+ hash->table [i] = s->next;
+ n = s->next;
+ } else {
+ last->next = s->next;
+ n = last->next;
+ }
+ g_free (s);
+ hash->in_use--;
+ count++;
+ s = n;
+ } else {
+ last = s;
+ s = s->next;
+ }
+ }
+ }
+ if (count > 0)
+ rehash (hash);
+ return count;
+}
+
void
g_hash_table_destroy (GHashTable *hash)
{
Modified: trunk/mono/eglib/src/glib.h
===================================================================
--- trunk/mono/eglib/src/glib.h 2007-10-31 18:50:00 UTC (rev 88600)
+++ trunk/mono/eglib/src/glib.h 2007-10-31 19:04:26 UTC (rev 88601)
@@ -168,6 +168,7 @@
gpointer g_hash_table_find (GHashTable *hash, GHRFunc
predicate, gpointer user_data);
gboolean g_hash_table_remove (GHashTable *hash, gconstpointer
key);
guint g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func,
gpointer user_data);
+guint g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func,
gpointer user_data);
void g_hash_table_destroy (GHashTable *hash);
guint g_spaced_primes_closest (guint x);
@@ -397,6 +398,7 @@
GArray *g_array_append_vals (GArray *array, gconstpointer data, guint
len);
GArray* g_array_insert_vals (GArray *array, guint index_, gconstpointer
data, guint len);
GArray* g_array_remove_index (GArray *array, guint index_);
+GArray* g_array_remove_index_fast (GArray *array, guint index_);
#define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
#define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
Modified: trunk/mono/eglib/src/gpath.c
===================================================================
--- trunk/mono/eglib/src/gpath.c 2007-10-31 18:50:00 UTC (rev 88600)
+++ trunk/mono/eglib/src/gpath.c 2007-10-31 19:04:26 UTC (rev 88601)
@@ -146,7 +146,15 @@
g_path_is_absolute (const char *filename)
{
g_return_val_if_fail (filename != NULL, FALSE);
+#ifdef G_OS_WIN32
+ if (filename[0] != '\0' && filename[1] != '\0' && filename[1] == ':' &&
+ filename[2] != '\0' && filename[2] == '\\')
+ return TRUE;
+ else
+ return FALSE;
+#else
return (*filename == '/');
+#endif
}
gchar *
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches