removed archaic gpointer derived_data; relict and added a GData member
authorTim Janik <timj@gtk.org>
Sun, 18 Mar 2001 04:44:38 +0000 (04:44 +0000)
committerTim Janik <timj@src.gnome.org>
Sun, 18 Mar 2001 04:44:38 +0000 (04:44 +0000)
Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>

        * gscanner.[hc]: removed archaic gpointer derived_data; relict and
        added a GData member instead.

        * glist.[hc]: added g_list_remove_all().

        * gslist.[hc]: added g_slist_remove_all().

Sat Mar 17 23:18:36 2001  Tim Janik  <timj@gtk.org>

        * gobject.c (g_object_get_property): minor bug-fix.

        * gbsearcharray.[hc]: provide a macro for static initialization and
        functions g_bsearch_array_new() and g_bsearch_array_destroy() for
        dynamic allocations.

        * gboxed.c: introduce G_TYPE_GSTRING, boxed type for GString.

        * gclosure.[hc]: naming corrections.

Fri Mar  9 16:42:08 2001  Tim Janik  <timj@gtk.org>

        * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as
        a public function (was static in gobject.c before). it's a bit odd
        to have that function here, especially since it requires extra includes,
        but then it doesn't very well fit somewhere else either.

        * gparamspecs.c: added default/max/min checks to param spec creation
        functions.

43 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/reference/glib/tmpl/macros_misc.sgml
docs/reference/glib/tmpl/scanner.sgml
docs/reference/gobject/tmpl/closures.sgml
docs/reference/gobject/tmpl/gobject-unused.sgml
docs/reference/gobject/tmpl/types.sgml
glib/gbsearcharray.c
glib/gbsearcharray.h
glib/glist.c
glib/glist.h
glib/gscanner.c
glib/gscanner.h
glib/gslist.c
glib/gslist.h
glib/gtypes.h
glist.c
glist.h
gobject/ChangeLog
gobject/gboxed.c
gobject/gbsearcharray.c
gobject/gbsearcharray.h
gobject/gclosure.c
gobject/gclosure.h
gobject/gobject.c
gobject/gparam.c
gobject/gsignal.c
gobject/gtype.h
gobject/gvalue.c
gobject/gvaluecollector.h
gobject/gvaluetypes.c
gobject/gvaluetypes.h
gscanner.c
gscanner.h
gslist.c
gslist.h
gtypes.h

index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index 3c08807186abdf270ac7b0405ea9272f1877d9c1..fd39c95953fc88178d361b77a331b476c35d9bf6 100644 (file)
@@ -1,3 +1,12 @@
+Wed Mar 14 18:46:54 2001  Tim Janik  <timj@gtk.org>
+
+       * gscanner.[hc]: removed archaic gpointer derived_data; relict and
+       added a GData member instead.
+       
+       * glist.[hc]: added g_list_remove_all().
+
+       * gslist.[hc]: added g_slist_remove_all().
+
 Sat Mar 17 19:54:51 2001  Owen Taylor  <otaylor@redhat.com>
 
        * timeloop.c: Reorder headers to make FreeBSD happy. 
index a7768c73393efb09ae48e1ac2e2ca7ed613baed0..994ffb73084ffa3a8f1eff2538277a36cd181022 100644 (file)
@@ -66,6 +66,7 @@ only one statement is expected by the compiler.
 Portable way to copy <type>va_list</type> variables.
 </para>
 
+<!-- # Unused Parameters # -->
 @ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
 @ap2: a <type>va_list</type>.
 
index 099924fe3bacebeb3822709f5ebecf6590e3e112..1aeab65235fc428c3aefa33f50cc9436592081fe 100644 (file)
@@ -43,7 +43,7 @@ handler function is declared by #GScannerMsgFunc.
 @max_parse_errors: 
 @parse_errors: 
 @input_name: 
-@derived_data: 
+@qdata: 
 @config: 
 @token: 
 @value: 
index 1fc7fb7484a91ea6c87a774370fa731fccbc4d2d..9647d62d18cc2e769d9a44497119cda1b0b1b250 100644 (file)
@@ -178,46 +178,6 @@ Closures
 @closure: 
 
 
-<!-- ##### FUNCTION g_closure_add_fnotify ##### -->
-<para>
-
-</para>
-
-@closure: 
-@notify_data: 
-@notify_func: 
-
-
-<!-- ##### FUNCTION g_closure_remove_fnotify ##### -->
-<para>
-
-</para>
-
-@closure: 
-@notify_data: 
-@notify_func: 
-
-
-<!-- ##### FUNCTION g_closure_add_inotify ##### -->
-<para>
-
-</para>
-
-@closure: 
-@notify_data: 
-@notify_func: 
-
-
-<!-- ##### FUNCTION g_closure_remove_inotify ##### -->
-<para>
-
-</para>
-
-@closure: 
-@notify_data: 
-@notify_func: 
-
-
 <!-- ##### FUNCTION g_closure_new_simple ##### -->
 <para>
 
index fff0ee7eef8e1cbe5b9a78ba55a2f7a17c796424..0f00a4544faabd6322d8da0b19b8c18e2e574056 100644 (file)
@@ -1,3 +1,39 @@
+<!-- ##### FUNCTION g_closure_add_fnotify ##### -->
+<para>
+
+</para>
+
+@closure: 
+@notify_data: 
+@notify_func: 
+
+<!-- ##### FUNCTION g_closure_add_inotify ##### -->
+<para>
+
+</para>
+
+@closure: 
+@notify_data: 
+@notify_func: 
+
+<!-- ##### FUNCTION g_closure_remove_fnotify ##### -->
+<para>
+
+</para>
+
+@closure: 
+@notify_data: 
+@notify_func: 
+
+<!-- ##### FUNCTION g_closure_remove_inotify ##### -->
+<para>
+
+</para>
+
+@closure: 
+@notify_data: 
+@notify_func: 
+
 <!-- ##### FUNCTION g_param_spec_string_c ##### -->
 <para>
 
index 4aa4b014e15f2c61d0a76f34d2534024a96ec914..2eab8c31ba01e724cab1a2ac402acce75b93272a 100644 (file)
@@ -203,6 +203,7 @@ The predefined identifiers of the reserved fundamental types.
 @G_TYPE_CLOSURE: 
 @G_TYPE_VALUE: 
 @G_TYPE_VALUE_ARRAY: 
+@G_TYPE_GSTRING: 
 @G_TYPE_PARAM_CHAR:            Identifier for the "#GParamSpecChar" type.
 @G_TYPE_PARAM_UCHAR:           Identifier for the "#GParamSpecUChar" type.
 @G_TYPE_PARAM_BOOLEAN:                 Identifier for the "#GParamSpecBoolean" type.
index 9a8dbcf8e0aa80adbb070137e577fd32f92fe7ee..3343e8477dd8c87f8c5dcb9734c32c7831ce8d4b 100644 (file)
 
 
 /* --- structures --- */
+GBSearchArray*
+g_bsearch_array_new (guint16             sizeof_node,
+                    GBSearchCompareFunc node_cmp_func,
+                    GBSearchArrayFlags  flags)
+{
+  GBSearchArray *barray;
+
+  g_return_val_if_fail (sizeof_node > 0, NULL);
+  g_return_val_if_fail (node_cmp_func != NULL, NULL);
+
+  barray = g_new0 (GBSearchArray, 1);
+  barray->sizeof_node = sizeof_node;
+  barray->cmp_nodes = node_cmp_func;
+  barray->flags = flags;
+
+  return barray;
+}
+
+void
+g_bsearch_array_destroy (GBSearchArray *barray)
+{
+  g_return_if_fail (barray != NULL);
+
+#if 0
+  if (barray->destroy_node)
+    while (barray->n_nodes)
+      {
+       barray->destroy_node (((guint8*) barray->nodes) + (barray->n_nodes - 1) * barray->sizeof_node);
+       barray->n_nodes--;
+      }
+#endif
+  g_free (barray->nodes);
+  g_free (barray);
+}
+
 static inline guint
 upper_power2 (guint number)
 {
@@ -47,16 +82,15 @@ bsearch_array_insert (GBSearchArray *barray,
     {
       guint new_size = barray->sizeof_node;
       
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        new_size = upper_power2 (new_size);
       barray->nodes = g_realloc (barray->nodes, new_size);
       barray->n_nodes = 1;
       check = barray->nodes;
-      replace = TRUE;
     }
   else
     {
-      GBSearchCompareFunc cmp_func = barray->cmp_func;
+      GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
       guint n_nodes = barray->n_nodes;
       guint8 *nodes = barray->nodes;
       gint cmp;
@@ -67,7 +101,7 @@ bsearch_array_insert (GBSearchArray *barray,
        {
          i = (n_nodes + 1) >> 1;
          check = nodes + i * sizeof_node;
-         cmp = cmp_func (key_node, check);
+         cmp = cmp_nodes (key_node, check);
          if (cmp > 0)
            {
              n_nodes -= i;
@@ -76,7 +110,17 @@ bsearch_array_insert (GBSearchArray *barray,
          else if (cmp < 0)
            n_nodes = i - 1;
          else /* if (cmp == 0) */
-           goto SKIP_GROW;
+           {
+             if (replace)
+               {
+#if 0
+                 if (barray->destroy_node)
+                   barray->destroy_node (check);
+#endif
+                 memcpy (check, key_node, sizeof_node);
+               }
+             return check;
+           }
        }
       while (n_nodes);
       /* grow */
@@ -84,7 +128,7 @@ bsearch_array_insert (GBSearchArray *barray,
        check += sizeof_node;
       i = (check - ((guint8*) barray->nodes)) / sizeof_node;
       n_nodes = barray->n_nodes++;
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        {
          guint new_size = upper_power2 (barray->n_nodes * sizeof_node);
          guint old_size = upper_power2 (n_nodes * sizeof_node);
@@ -96,12 +140,8 @@ bsearch_array_insert (GBSearchArray *barray,
        barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
       check = ((guint8*) barray->nodes) + i * sizeof_node;
       g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
-      replace = TRUE;
-    SKIP_GROW:
-      ;
     }
-  if (replace)
-    memcpy (check, key_node, sizeof_node);
+  memcpy (check, key_node, sizeof_node);
   
   return check;
 }
@@ -132,16 +172,20 @@ g_bsearch_array_remove_node (GBSearchArray *barray,
   bound = nodes + old_size;
   
   g_return_if_fail (node_in_array >= nodes && node_in_array < bound);
-  
+
+#if 0
+  if (barray->destroy_node)
+    barray->destroy_node (node_in_array);
+#endif
   bound -= barray->sizeof_node;
   barray->n_nodes -= 1;
   g_memmove (node_in_array, node_in_array + barray->sizeof_node, (bound - node_in_array) / barray->sizeof_node);
   
-  if ((barray->flags & G_BSEARCH_DEFER_SHRINK) == 0)
+  if ((barray->flags & G_BSEARCH_ARRAY_DEFER_SHRINK) == 0)
     {
       guint new_size = bound - nodes;   /* old_size - barray->sizeof_node */
       
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        {
          new_size = upper_power2 (new_size);
          old_size = upper_power2 (old_size);
index dc23ffd20d5b6bd4b09ea75568001677ab32b8ee..e4b9201e9cd5edb6491026a5d7bff58cbcffe24f 100644 (file)
@@ -35,23 +35,27 @@ typedef gint  (*GBSearchCompareFunc) (gconstpointer bsearch_node1,
                                      gconstpointer bsearch_node2);
 typedef enum
 {
-  G_BSEARCH_ALIGN_POWER2       = 1 << 0,
-  G_BSEARCH_DEFER_SHRINK       = 1 << 1
-} GBSearchFlags;
+  G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0,
+  G_BSEARCH_ARRAY_DEFER_SHRINK = 1 << 1
+} GBSearchArrayFlags;
 
 
 /* --- structures --- */
 struct _GBSearchArray
 {
-  GBSearchCompareFunc cmp_func;
-  guint16             sizeof_node;
+  GBSearchCompareFunc cmp_nodes;
   guint16            flags;
+  guint16             sizeof_node;
   guint               n_nodes;
   gpointer            nodes;
 };
 
 
 /* --- prototypes --- */
+GBSearchArray* g_bsearch_array_new             (guint16             sizeof_node,
+                                                GBSearchCompareFunc node_cmp_func,
+                                                GBSearchArrayFlags  flags);
+void           g_bsearch_array_destroy         (GBSearchArray  *barray);
 gpointer       g_bsearch_array_insert          (GBSearchArray  *barray,
                                                 gconstpointer   key_node,
                                                 gboolean        replace_existing);
@@ -70,6 +74,11 @@ guint                g_bsearch_array_get_index       (GBSearchArray  *barray,
                                                 gpointer        node_in_array);
 
 
+/* initialization of static arrays */
+#define        G_STATIC_BSEARCH_ARRAY_INIT(sizeof_node, cmp_nodes, flags) \
+  { (cmp_nodes), (flags), (sizeof_node), 0, NULL }
+
+
 /* --- implementation details --- */
 #if defined (G_CAN_INLINE) || defined (__G_BSEARCHARRAY_C__)
 G_INLINE_FUNC gpointer
@@ -78,7 +87,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
 {
   if (barray->n_nodes > 0)
     {
-      GBSearchCompareFunc cmp_func = barray->cmp_func;
+      GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
       gint sizeof_node = barray->sizeof_node;
       guint n_nodes = barray->n_nodes;
       guint8 *nodes = (guint8 *) barray->nodes;
@@ -92,7 +101,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
          
          i = (n_nodes + 1) >> 1;
          check = nodes + i * sizeof_node;
-         cmp = cmp_func (key_node, check);
+         cmp = cmp_nodes (key_node, check);
          if (cmp == 0)
            return check;
          else if (cmp > 0)
index e629b1a204f4a50b9c074c2d9acc942d243857c9..3d24bd2a6094f2f3638074de2273c0cefe02a6d3 100644 (file)
@@ -364,6 +364,34 @@ g_list_remove (GList            *list,
   return list;
 }
 
+GList*
+g_list_remove_all (GList       *list,
+                  gconstpointer data)
+{
+  GList *tmp = list;
+
+  while (tmp)
+    {
+      if (tmp->data != data)
+       tmp = tmp->next;
+      else
+       {
+         GList *next = tmp->next;
+
+         if (tmp->prev)
+           tmp->prev->next = next;
+         else
+           list = next;
+         if (next)
+           next->prev = tmp->prev;
+
+         _g_list_free_1 (tmp);
+         tmp = next;
+       }
+    }
+  return list;
+}
+
 static inline GList*
 _g_list_remove_link (GList *list,
                     GList *link)
index 7b3e977a5e82f27e6e5c2ac353786cc97ab61711..c871b538165eaa555eb1e0c4409db287272d5d2b 100644 (file)
@@ -61,6 +61,8 @@ GList*   g_list_concat         (GList            *list1,
                                GList            *list2);
 GList*   g_list_remove         (GList            *list,
                                gconstpointer     data);
+GList*   g_list_remove_all     (GList            *list,
+                               gconstpointer     data);
 GList*   g_list_remove_link    (GList            *list,
                                GList            *llink);
 GList*   g_list_delete_link    (GList            *list,
index 540aa39a9862aaac4163917262e94d148c99744a..cf73a04d4fd218abd1b470fe874a32d6638a407c 100644 (file)
@@ -184,7 +184,7 @@ g_scanner_new (const GScannerConfig *config_templ)
   scanner->max_parse_errors = 0;
   scanner->parse_errors        = 0;
   scanner->input_name = NULL;
-  scanner->derived_data = NULL;
+  g_datalist_init (&scanner->qdata);
   
   scanner->config = g_new0 (GScannerConfig, 1);
   
@@ -275,6 +275,7 @@ g_scanner_destroy (GScanner *scanner)
 {
   g_return_if_fail (scanner != NULL);
   
+  g_datalist_clear (&scanner->qdata);
   g_hash_table_foreach (scanner->symbol_table, 
                        g_scanner_destroy_symbol_table_entry, NULL);
   g_hash_table_destroy (scanner->symbol_table);
index f489745d7736b7a48be867e176778adf28eeef98..4b9a07cbea57a93d9db8ac5f5bd00259c80a4996 100644 (file)
@@ -168,8 +168,8 @@ struct      _GScanner
   /* name of input stream, featured by the default message handler */
   const gchar          *input_name;
   
-  /* data pointer for derived structures */
-  gpointer             derived_data;
+  /* quarked data */
+  GData                        *qdata;
   
   /* link into the scanner configuration */
   GScannerConfig       *config;
index 65c2c6cdb956fbb8aeb8fb00c7c97c1ed1a72a64..5577fb3265d9f35ba3994c7842e10084c0df2484 100644 (file)
@@ -325,29 +325,54 @@ GSList*
 g_slist_remove (GSList        *list,
                gconstpointer  data)
 {
-  GSList *tmp;
-  GSList *prev;
+  GSList *tmp, *prev = NULL;
 
-  prev = NULL;
   tmp = list;
-
   while (tmp)
     {
       if (tmp->data == data)
        {
          if (prev)
            prev->next = tmp->next;
-         if (list == tmp)
-           list = list->next;
-
-         tmp->next = NULL;
-         g_slist_free (tmp);
+         else
+           list = tmp->next;
 
+         g_slist_free_1 (tmp);
          break;
        }
-
       prev = tmp;
-      tmp = tmp->next;
+      tmp = prev->next;
+    }
+
+  return list;
+}
+
+GSList*
+g_slist_remove_all (GSList        *list,
+                   gconstpointer  data)
+{
+  GSList *tmp, *prev = NULL;
+
+  tmp = list;
+  while (tmp)
+    {
+      if (tmp->data == data)
+       {
+         GSList *next = tmp->next;
+
+         if (prev)
+           prev->next = next;
+         else
+           list = next;
+         
+         g_slist_free_1 (tmp);
+         tmp = next;
+       }
+      else
+       {
+         prev = tmp;
+         tmp = prev->next;
+       }
     }
 
   return list;
index 8d94b2c075975725c22bc907089402f32eab9d29..00d3fc336990e491488085d74c48f2e9cb38d9af 100644 (file)
@@ -63,6 +63,8 @@ GSList*  g_slist_concat         (GSList           *list1,
                                 GSList           *list2);
 GSList*  g_slist_remove         (GSList           *list,
                                 gconstpointer     data);
+GSList*  g_slist_remove_all     (GSList           *list,
+                                gconstpointer     data);
 GSList*  g_slist_remove_link    (GSList           *list,
                                 GSList           *link);
 GSList*  g_slist_delete_link    (GSList           *list,
index 29c4de81c9ca73f200e9fd8e846ee595c0d73516..eec6fa42a10a89bba0950cae926585b315f64b36 100644 (file)
@@ -43,7 +43,6 @@ typedef short  gshort;
 typedef long   glong;
 typedef int    gint;
 typedef gint   gboolean;
-typedef gchar* gstring;
 
 typedef unsigned char   guchar;
 typedef unsigned short  gushort;
diff --git a/glist.c b/glist.c
index e629b1a204f4a50b9c074c2d9acc942d243857c9..3d24bd2a6094f2f3638074de2273c0cefe02a6d3 100644 (file)
--- a/glist.c
+++ b/glist.c
@@ -364,6 +364,34 @@ g_list_remove (GList            *list,
   return list;
 }
 
+GList*
+g_list_remove_all (GList       *list,
+                  gconstpointer data)
+{
+  GList *tmp = list;
+
+  while (tmp)
+    {
+      if (tmp->data != data)
+       tmp = tmp->next;
+      else
+       {
+         GList *next = tmp->next;
+
+         if (tmp->prev)
+           tmp->prev->next = next;
+         else
+           list = next;
+         if (next)
+           next->prev = tmp->prev;
+
+         _g_list_free_1 (tmp);
+         tmp = next;
+       }
+    }
+  return list;
+}
+
 static inline GList*
 _g_list_remove_link (GList *list,
                     GList *link)
diff --git a/glist.h b/glist.h
index 7b3e977a5e82f27e6e5c2ac353786cc97ab61711..c871b538165eaa555eb1e0c4409db287272d5d2b 100644 (file)
--- a/glist.h
+++ b/glist.h
@@ -61,6 +61,8 @@ GList*   g_list_concat         (GList            *list1,
                                GList            *list2);
 GList*   g_list_remove         (GList            *list,
                                gconstpointer     data);
+GList*   g_list_remove_all     (GList            *list,
+                               gconstpointer     data);
 GList*   g_list_remove_link    (GList            *list,
                                GList            *llink);
 GList*   g_list_delete_link    (GList            *list,
index 5510242e8402b88bb4e6c64ce8e8fb1b76782b49..880b4c3e0a74d489c841694cc31728d9045fdc1d 100644 (file)
@@ -1,3 +1,15 @@
+Sat Mar 17 23:18:36 2001  Tim Janik  <timj@gtk.org>
+
+       * gobject.c (g_object_get_property): minor bug-fix.
+
+       * gbsearcharray.[hc]: provide a macro for static initialization and
+       functions g_bsearch_array_new() and g_bsearch_array_destroy() for
+       dynamic allocations.
+       
+       * gboxed.c: introduce G_TYPE_GSTRING, boxed type for GString.
+       
+       * gclosure.[hc]: naming corrections.
+
 Fri Mar  9 16:42:08 2001  Tim Janik  <timj@gtk.org>
 
        * gvaluetypes.[hc]: moved g_strdup_value_contents() into this file as
index 7dd240b7d7c741dacaaa3fb618c5d239e9d868c1..2924622fd7fb48d81db20baa44276a50f277111e 100644 (file)
@@ -43,7 +43,7 @@ static gint   boxed_nodes_cmp         (gconstpointer  p1,
 
 
 /* --- variables --- */
-static GBSearchArray boxed_bsa = { boxed_nodes_cmp, sizeof (BoxedNode), 0, 0, NULL };
+static GBSearchArray boxed_bsa = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (BoxedNode), boxed_nodes_cmp, 0);
 
 
 /* --- functions --- */
@@ -94,6 +94,28 @@ value_array_init (void)
   return g_value_array_new (0);
 }
 
+static gpointer
+gstring_init (void)
+{
+  return g_string_new ("");
+}
+
+static gpointer
+gstring_copy (gpointer boxed)
+{
+  const GString *src_gstring = boxed;
+
+  return g_string_new_len (src_gstring->str, src_gstring->len);
+}
+
+static void
+gstring_free (gpointer boxed)
+{
+  GString *gstring = boxed;
+
+  g_string_free (gstring, TRUE);
+}
+
 void
 g_boxed_type_init (void)  /* sync with gtype.c */
 {
@@ -144,6 +166,16 @@ g_boxed_type_init (void)  /* sync with gtype.c */
                                       (GBoxedFreeFunc) g_value_array_free,
                                       FALSE);
   g_assert (type == G_TYPE_VALUE_ARRAY);
+
+  /* boxed: G_TYPE_GSTRING
+   * yes, the naming is a bit odd, but GString is obviously not G_TYPE_STRING
+   */
+  type = g_boxed_type_register_static ("GString",
+                                      gstring_init,            /* don't allow NULL values */
+                                      gstring_copy,
+                                      gstring_free,
+                                      FALSE);
+  g_assert (type == G_TYPE_GSTRING);
 }
 
 static void
index 9a8dbcf8e0aa80adbb070137e577fd32f92fe7ee..3343e8477dd8c87f8c5dcb9734c32c7831ce8d4b 100644 (file)
 
 
 /* --- structures --- */
+GBSearchArray*
+g_bsearch_array_new (guint16             sizeof_node,
+                    GBSearchCompareFunc node_cmp_func,
+                    GBSearchArrayFlags  flags)
+{
+  GBSearchArray *barray;
+
+  g_return_val_if_fail (sizeof_node > 0, NULL);
+  g_return_val_if_fail (node_cmp_func != NULL, NULL);
+
+  barray = g_new0 (GBSearchArray, 1);
+  barray->sizeof_node = sizeof_node;
+  barray->cmp_nodes = node_cmp_func;
+  barray->flags = flags;
+
+  return barray;
+}
+
+void
+g_bsearch_array_destroy (GBSearchArray *barray)
+{
+  g_return_if_fail (barray != NULL);
+
+#if 0
+  if (barray->destroy_node)
+    while (barray->n_nodes)
+      {
+       barray->destroy_node (((guint8*) barray->nodes) + (barray->n_nodes - 1) * barray->sizeof_node);
+       barray->n_nodes--;
+      }
+#endif
+  g_free (barray->nodes);
+  g_free (barray);
+}
+
 static inline guint
 upper_power2 (guint number)
 {
@@ -47,16 +82,15 @@ bsearch_array_insert (GBSearchArray *barray,
     {
       guint new_size = barray->sizeof_node;
       
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        new_size = upper_power2 (new_size);
       barray->nodes = g_realloc (barray->nodes, new_size);
       barray->n_nodes = 1;
       check = barray->nodes;
-      replace = TRUE;
     }
   else
     {
-      GBSearchCompareFunc cmp_func = barray->cmp_func;
+      GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
       guint n_nodes = barray->n_nodes;
       guint8 *nodes = barray->nodes;
       gint cmp;
@@ -67,7 +101,7 @@ bsearch_array_insert (GBSearchArray *barray,
        {
          i = (n_nodes + 1) >> 1;
          check = nodes + i * sizeof_node;
-         cmp = cmp_func (key_node, check);
+         cmp = cmp_nodes (key_node, check);
          if (cmp > 0)
            {
              n_nodes -= i;
@@ -76,7 +110,17 @@ bsearch_array_insert (GBSearchArray *barray,
          else if (cmp < 0)
            n_nodes = i - 1;
          else /* if (cmp == 0) */
-           goto SKIP_GROW;
+           {
+             if (replace)
+               {
+#if 0
+                 if (barray->destroy_node)
+                   barray->destroy_node (check);
+#endif
+                 memcpy (check, key_node, sizeof_node);
+               }
+             return check;
+           }
        }
       while (n_nodes);
       /* grow */
@@ -84,7 +128,7 @@ bsearch_array_insert (GBSearchArray *barray,
        check += sizeof_node;
       i = (check - ((guint8*) barray->nodes)) / sizeof_node;
       n_nodes = barray->n_nodes++;
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        {
          guint new_size = upper_power2 (barray->n_nodes * sizeof_node);
          guint old_size = upper_power2 (n_nodes * sizeof_node);
@@ -96,12 +140,8 @@ bsearch_array_insert (GBSearchArray *barray,
        barray->nodes = g_realloc (barray->nodes, barray->n_nodes * sizeof_node);
       check = ((guint8*) barray->nodes) + i * sizeof_node;
       g_memmove (check + sizeof_node, check, (n_nodes - i) * sizeof_node);
-      replace = TRUE;
-    SKIP_GROW:
-      ;
     }
-  if (replace)
-    memcpy (check, key_node, sizeof_node);
+  memcpy (check, key_node, sizeof_node);
   
   return check;
 }
@@ -132,16 +172,20 @@ g_bsearch_array_remove_node (GBSearchArray *barray,
   bound = nodes + old_size;
   
   g_return_if_fail (node_in_array >= nodes && node_in_array < bound);
-  
+
+#if 0
+  if (barray->destroy_node)
+    barray->destroy_node (node_in_array);
+#endif
   bound -= barray->sizeof_node;
   barray->n_nodes -= 1;
   g_memmove (node_in_array, node_in_array + barray->sizeof_node, (bound - node_in_array) / barray->sizeof_node);
   
-  if ((barray->flags & G_BSEARCH_DEFER_SHRINK) == 0)
+  if ((barray->flags & G_BSEARCH_ARRAY_DEFER_SHRINK) == 0)
     {
       guint new_size = bound - nodes;   /* old_size - barray->sizeof_node */
       
-      if (barray->flags & G_BSEARCH_ALIGN_POWER2)
+      if (barray->flags & G_BSEARCH_ARRAY_ALIGN_POWER2)
        {
          new_size = upper_power2 (new_size);
          old_size = upper_power2 (old_size);
index dc23ffd20d5b6bd4b09ea75568001677ab32b8ee..e4b9201e9cd5edb6491026a5d7bff58cbcffe24f 100644 (file)
@@ -35,23 +35,27 @@ typedef gint  (*GBSearchCompareFunc) (gconstpointer bsearch_node1,
                                      gconstpointer bsearch_node2);
 typedef enum
 {
-  G_BSEARCH_ALIGN_POWER2       = 1 << 0,
-  G_BSEARCH_DEFER_SHRINK       = 1 << 1
-} GBSearchFlags;
+  G_BSEARCH_ARRAY_ALIGN_POWER2 = 1 << 0,
+  G_BSEARCH_ARRAY_DEFER_SHRINK = 1 << 1
+} GBSearchArrayFlags;
 
 
 /* --- structures --- */
 struct _GBSearchArray
 {
-  GBSearchCompareFunc cmp_func;
-  guint16             sizeof_node;
+  GBSearchCompareFunc cmp_nodes;
   guint16            flags;
+  guint16             sizeof_node;
   guint               n_nodes;
   gpointer            nodes;
 };
 
 
 /* --- prototypes --- */
+GBSearchArray* g_bsearch_array_new             (guint16             sizeof_node,
+                                                GBSearchCompareFunc node_cmp_func,
+                                                GBSearchArrayFlags  flags);
+void           g_bsearch_array_destroy         (GBSearchArray  *barray);
 gpointer       g_bsearch_array_insert          (GBSearchArray  *barray,
                                                 gconstpointer   key_node,
                                                 gboolean        replace_existing);
@@ -70,6 +74,11 @@ guint                g_bsearch_array_get_index       (GBSearchArray  *barray,
                                                 gpointer        node_in_array);
 
 
+/* initialization of static arrays */
+#define        G_STATIC_BSEARCH_ARRAY_INIT(sizeof_node, cmp_nodes, flags) \
+  { (cmp_nodes), (flags), (sizeof_node), 0, NULL }
+
+
 /* --- implementation details --- */
 #if defined (G_CAN_INLINE) || defined (__G_BSEARCHARRAY_C__)
 G_INLINE_FUNC gpointer
@@ -78,7 +87,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
 {
   if (barray->n_nodes > 0)
     {
-      GBSearchCompareFunc cmp_func = barray->cmp_func;
+      GBSearchCompareFunc cmp_nodes = barray->cmp_nodes;
       gint sizeof_node = barray->sizeof_node;
       guint n_nodes = barray->n_nodes;
       guint8 *nodes = (guint8 *) barray->nodes;
@@ -92,7 +101,7 @@ g_bsearch_array_lookup (GBSearchArray *barray,
          
          i = (n_nodes + 1) >> 1;
          check = nodes + i * sizeof_node;
-         cmp = cmp_func (key_node, check);
+         cmp = cmp_nodes (key_node, check);
          if (cmp == 0)
            return check;
          else if (cmp > 0)
index 3fc3387c119f2a437047996db1046dbb0dd60c9a..79aa66c6e7ec5062f23d3278c5059d12d0ca9ec0 100644 (file)
@@ -221,9 +221,9 @@ g_closure_add_marshal_guards (GClosure      *closure,
 }
 
 void
-g_closure_add_fnotify (GClosure      *closure,
-                      gpointer       notify_data,
-                      GClosureNotify notify_func)
+g_closure_add_finalize_notifier (GClosure      *closure,
+                                gpointer       notify_data,
+                                GClosureNotify notify_func)
 {
   guint i;
 
@@ -243,9 +243,9 @@ g_closure_add_fnotify (GClosure      *closure,
 }
 
 void
-g_closure_add_inotify (GClosure      *closure,
-                      gpointer       notify_data,
-                      GClosureNotify notify_func)
+g_closure_add_invalidate_notifier (GClosure      *closure,
+                                  gpointer       notify_data,
+                                  GClosureNotify notify_func)
 {
   guint i;
 
@@ -371,9 +371,9 @@ g_closure_sink (GClosure *closure)
 }
 
 void
-g_closure_remove_inotify (GClosure      *closure,
-                         gpointer       notify_data,
-                         GClosureNotify notify_func)
+g_closure_remove_invalidate_notifier (GClosure      *closure,
+                                     gpointer       notify_data,
+                                     GClosureNotify notify_func)
 {
   g_return_if_fail (closure != NULL);
   g_return_if_fail (notify_func != NULL);
@@ -387,9 +387,9 @@ g_closure_remove_inotify (GClosure      *closure,
 }
 
 void
-g_closure_remove_fnotify (GClosure      *closure,
-                          gpointer       notify_data,
-                         GClosureNotify notify_func)
+g_closure_remove_finalize_notifier (GClosure      *closure,
+                                   gpointer       notify_data,
+                                   GClosureNotify notify_func)
 {
   g_return_if_fail (closure != NULL);
   g_return_if_fail (notify_func != NULL);
@@ -469,7 +469,7 @@ g_cclosure_new (GCallback      callback_func,
   
   closure = g_closure_new_simple (sizeof (GCClosure), user_data);
   if (destroy_data)
-    g_closure_add_fnotify (closure, user_data, destroy_data);
+    g_closure_add_finalize_notifier (closure, user_data, destroy_data);
   ((GCClosure*) closure)->callback = callback_func;
   
   return closure;
@@ -486,7 +486,7 @@ g_cclosure_new_swap (GCallback      callback_func,
   
   closure = g_closure_new_simple (sizeof (GCClosure), user_data);
   if (destroy_data)
-    g_closure_add_fnotify (closure, user_data, destroy_data);
+    g_closure_add_finalize_notifier (closure, user_data, destroy_data);
   ((GCClosure*) closure)->callback = callback_func;
   closure->derivative_flag = TRUE;
   
index 0057a818c0ba28e10a140d6fab1e81398bdec77a..39531d2dbf90554688587053a05a12ad1b84359c 100644 (file)
@@ -95,47 +95,47 @@ struct _GCClosure
 
 
 /* --- prototypes --- */
-GClosure*      g_cclosure_new                  (GCallback      callback_func,
+GClosure* g_cclosure_new                       (GCallback      callback_func,
                                                 gpointer       user_data,
                                                 GClosureNotify destroy_data);
-GClosure*      g_cclosure_new_swap             (GCallback      callback_func,
+GClosure* g_cclosure_new_swap                  (GCallback      callback_func,
                                                 gpointer       user_data,
                                                 GClosureNotify destroy_data);
-GClosure*      g_signal_type_cclosure_new      (GType          itype,
+GClosure* g_signal_type_cclosure_new           (GType          itype,
                                                 guint          struct_offset);
 
 
 /* --- prototypes --- */
-GClosure*      g_closure_ref                   (GClosure       *closure);
-void           g_closure_sink                  (GClosure       *closure);
-void           g_closure_unref                 (GClosure       *closure);
+GClosure* g_closure_ref                                (GClosure       *closure);
+void     g_closure_sink                        (GClosure       *closure);
+void     g_closure_unref                       (GClosure       *closure);
 /* intimidating */
-GClosure*      g_closure_new_simple            (guint           sizeof_closure,
+GClosure* g_closure_new_simple                 (guint           sizeof_closure,
                                                 gpointer        data);
-void           g_closure_add_fnotify           (GClosure       *closure,
+void     g_closure_add_finalize_notifier       (GClosure       *closure,
                                                 gpointer        notify_data,
                                                 GClosureNotify  notify_func);
-void           g_closure_remove_fnotify        (GClosure       *closure,
+void     g_closure_remove_finalize_notifier    (GClosure       *closure,
                                                 gpointer        notify_data,
                                                 GClosureNotify  notify_func);
-void           g_closure_add_inotify           (GClosure       *closure,
+void     g_closure_add_invalidate_notifier     (GClosure       *closure,
                                                 gpointer        notify_data,
                                                 GClosureNotify  notify_func);
-void           g_closure_remove_inotify        (GClosure       *closure,
+void     g_closure_remove_invalidate_notifier  (GClosure       *closure,
                                                 gpointer        notify_data,
                                                 GClosureNotify  notify_func);
-void           g_closure_add_marshal_guards    (GClosure       *closure,
+void     g_closure_add_marshal_guards          (GClosure       *closure,
                                                 gpointer        pre_marshal_data,
                                                 GClosureNotify  pre_marshal_notify,
                                                 gpointer        post_marshal_data,
                                                 GClosureNotify  post_marshal_notify);
-void           g_closure_set_marshal           (GClosure       *closure,
+void     g_closure_set_marshal                 (GClosure       *closure,
                                                 GClosureMarshal marshal);
-void           g_closure_set_meta_marshal      (GClosure       *closure,
+void     g_closure_set_meta_marshal            (GClosure       *closure,
                                                 gpointer        marshal_data,
                                                 GClosureMarshal meta_marshal);
-void           g_closure_invalidate            (GClosure       *closure);
-void           g_closure_invoke                (GClosure       *closure,
+void     g_closure_invalidate                  (GClosure       *closure);
+void     g_closure_invoke                      (GClosure       *closure,
                                                 GValue /*out*/ *return_value,
                                                 guint           n_param_values,
                                                 const GValue   *param_values,
index 1f269c79806ee5d40cef14412022a3bc0cc7315a..f3e0e49f3e70885a00ad30f7b5784f03404a570e 100644 (file)
@@ -661,7 +661,7 @@ object_set_property (GObject      *object,
     {
       gchar *contents = g_strdup_value_contents (value);
 
-      g_warning ("value <%s> of type `%s' is invalid for property `%s' of type `%s'",
+      g_warning ("value \"%s\" of type `%s' is invalid for property `%s' of type `%s'",
                 contents,
                 G_VALUE_TYPE_NAME (value),
                 pspec->name,
@@ -985,10 +985,7 @@ g_object_get_valist (GObject        *object,
        {
          g_warning ("%s: %s", G_STRLOC, error);
          g_free (error);
-         
-         /* we purposely leak the value here, it might not be
-          * in a sane state if an error condition occoured
-          */
+         g_value_unset (&value);
          break;
        }
       
@@ -1052,7 +1049,8 @@ g_object_set_property (GObject        *object,
                                    G_OBJECT_TYPE (object),
                                    TRUE);
   if (!pspec)
-    g_warning ("object class `%s' has no property named `%s'",
+    g_warning ("%s: object class `%s' has no property named `%s'",
+              G_STRLOC,
               G_OBJECT_TYPE_NAME (object),
               property_name);
   else
@@ -1080,7 +1078,8 @@ g_object_get_property (GObject       *object,
                                    G_OBJECT_TYPE (object),
                                    TRUE);
   if (!pspec)
-    g_warning ("object class `%s' has no property named `%s'",
+    g_warning ("%s: object class `%s' has no property named `%s'",
+              G_STRLOC,
               G_OBJECT_TYPE_NAME (object),
               property_name);
   else
@@ -1100,6 +1099,7 @@ g_object_get_property (GObject       *object,
                     pspec->name,
                     g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)),
                     G_VALUE_TYPE_NAME (value));
+         g_object_unref (object);
          return;
        }
       else
@@ -1536,7 +1536,7 @@ destroy_closure_array (gpointer data)
       /* removing object_remove_closure() upfront is probably faster than
        * letting it fiddle with quark_closure_array which is empty anyways
        */
-      g_closure_remove_inotify (closure, object, object_remove_closure);
+      g_closure_remove_invalidate_notifier (closure, object, object_remove_closure);
       g_closure_invalidate (closure);
     }
   g_free (carray);
@@ -1554,7 +1554,7 @@ g_object_watch_closure (GObject  *object,
   g_return_if_fail (closure->in_marshal == FALSE);
   g_return_if_fail (object->ref_count > 0);    /* this doesn't work on finalizing objects */
   
-  g_closure_add_inotify (closure, object, object_remove_closure);
+  g_closure_add_invalidate_notifier (closure, object, object_remove_closure);
   g_closure_add_marshal_guards (closure,
                                object, (GClosureNotify) g_object_ref,
                                object, (GClosureNotify) g_object_unref);
index 5a1dff4a4b1aed5be3a8bf6966cdcc4e9afd2302..72af807e21c2c4ff77d243fdeb5f926bf04b9dd5 100644 (file)
@@ -244,6 +244,7 @@ g_param_spec_internal (GType        param_type,
 
   g_return_val_if_fail (G_TYPE_IS_PARAM (param_type) && param_type != G_TYPE_PARAM, NULL);
   g_return_val_if_fail (name != NULL, NULL);
+  g_return_val_if_fail ((name[0] >= 'A' && name[0] <= 'Z') || (name[0] >= 'a' && name[0] <= 'z'), NULL);
 
   pspec = (gpointer) g_type_create_instance (param_type);
   pspec->name = g_strdup (name);
@@ -621,7 +622,7 @@ param_spec_ht_lookup (GHashTable  *hash_table,
 
   if (!pspec)
     {
-      /* sigh, try canonicalization */
+      /* try canonicalized form */
       key.name = g_strdup (param_name);
       key.owner_type = owner_type;
       
index 391b365e52c4f6778dc431ac8bc7c490e71e6d96..c5183210e3bb11e7700a23b4a4a14387ae6f5e7c 100644 (file)
@@ -35,7 +35,6 @@
 /* pre allocation configurations
  */
 #define        MAX_STACK_VALUES        (16)
-#define BSA_PRE_ALLOC           (20)
 #define HANDLER_PRE_ALLOC       (48)
 #define EMISSION_PRE_ALLOC      (16)
 
@@ -141,6 +140,8 @@ static inline Emission*             emission_find           (Emission        *emission_list,
                                                         guint            signal_id,
                                                         GQuark           detail,
                                                         gpointer         instance);
+static gint                    signal_key_cmp          (gconstpointer    node1,
+                                                        gconstpointer    node2);
 static       gboolean          signal_emit_R           (SignalNode      *node,
                                                         GQuark           detail,
                                                         gpointer         instance,
@@ -226,11 +227,12 @@ struct _HandlerMatch
 
 
 /* --- variables --- */
-static GBSearchArray  g_signal_key_bsa = { NULL, 0, 0, 0, NULL };
+static GBSearchArray  g_signal_key_bsa = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (SignalKey),
+                                                                     signal_key_cmp,
+                                                                     G_BSEARCH_ARRAY_ALIGN_POWER2);
 static GHashTable    *g_handler_list_bsa_ht = NULL;
 static Emission      *g_recursive_emissions = NULL;
 static Emission      *g_restart_emissions = NULL;
-static GTrashStack   *g_bsa_ts = NULL;
 static GTrashStack   *g_handler_ts = NULL;
 static GTrashStack   *g_emission_ts = NULL;
 G_LOCK_DEFINE_STATIC (g_signal_mutex);
@@ -314,14 +316,7 @@ handler_list_ensure (guint    signal_id,
   
   if (!hlbsa)
     {
-      hlbsa = g_generic_node_alloc (&g_bsa_ts,
-                                    sizeof (GBSearchArray),
-                                    BSA_PRE_ALLOC);
-      hlbsa->cmp_func = handler_lists_cmp;
-      hlbsa->sizeof_node = sizeof (HandlerList);
-      hlbsa->flags = G_BSEARCH_DEFER_SHRINK;
-      hlbsa->n_nodes = 0;
-      hlbsa->nodes = NULL;
+      hlbsa = g_bsearch_array_new (sizeof (HandlerList), handler_lists_cmp, G_BSEARCH_ARRAY_DEFER_SHRINK);
       g_hash_table_insert (g_handler_list_bsa_ht, instance, hlbsa);
     }
   key.signal_id = signal_id;
@@ -658,11 +653,6 @@ g_signal_init (void) /* sync with gtype.c */
       /* handler_id_node_prepend() requires this */
       g_assert (sizeof (GList) == sizeof (HandlerMatch));
       
-      /* setup signal key array */
-      g_signal_key_bsa.cmp_func = signal_key_cmp;
-      g_signal_key_bsa.sizeof_node = sizeof (SignalKey);
-      g_signal_key_bsa.flags = G_BSEARCH_ALIGN_POWER2; /* alloc-only */
-      
       /* setup handler list binary searchable array hash table (in german, that'd be one word ;) */
       g_handler_list_bsa_ht = g_hash_table_new (g_direct_hash, NULL);
       
@@ -983,7 +973,7 @@ g_signal_list_ids (GType  itype,
   
   G_UNLOCK (g_signal_mutex);
   
-  return (guint *) g_array_free (result, FALSE);
+  return (guint*) g_array_free (result, FALSE);
 }
 
 guint
@@ -1452,8 +1442,7 @@ g_signal_handlers_destroy (gpointer instance)
                }
             }
         }
-      g_free (hlbsa->nodes);
-      g_generic_node_free (&g_bsa_ts, hlbsa);
+      g_bsearch_array_destroy (hlbsa);
     }
   G_UNLOCK (g_signal_mutex);
 }
index 9031e27dfb6ed49712c852f00912c4ac9777aafb..9776edfa52b500d0273657c11263a7ceca68efd2 100644 (file)
@@ -71,6 +71,7 @@ typedef enum    /*< skip >*/
   G_TYPE_CLOSURE               = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 1),
   G_TYPE_VALUE                 = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 2),
   G_TYPE_VALUE_ARRAY           = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 3),
+  G_TYPE_GSTRING               = G_TYPE_DERIVE_ID (G_TYPE_BOXED, 4),
   G_TYPE_PARAM_CHAR            = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 1),
   G_TYPE_PARAM_UCHAR           = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 2),
   G_TYPE_PARAM_BOOLEAN         = G_TYPE_DERIVE_ID (G_TYPE_PARAM, 3),
index 70a04d312bf8badb7fe80a416cf9721067f13377..7fd36f78be8ff5bafb86a72be185b25700f0b1a1 100644 (file)
@@ -42,12 +42,9 @@ static gint  transform_entries_cmp   (gconstpointer bsearch_node1,
 
 
 /* --- variables --- */
-static GBSearchArray transform_array = {
-  transform_entries_cmp,
-  sizeof (TransformEntry),
-  0, /* no flags */
-  0, NULL,
-};
+static GBSearchArray transform_array = G_STATIC_BSEARCH_ARRAY_INIT (sizeof (TransformEntry),
+                                                                   transform_entries_cmp,
+                                                                   0);
 
 
 /* --- functions --- */
index 04522de852e71443abea2af250e054866f8af833..5f0cbbf563cc128731eb126d944614f7bb098614 100644 (file)
@@ -106,7 +106,7 @@ G_STMT_START {                                                                              \
  */
 #define G_VALUE_LCOPY(value, var_args, flags, __error)                                 \
 G_STMT_START {                                                                         \
-  GValue *_value = (value);                                                            \
+  const GValue *_value = (value);                                                      \
   guint _flags = (flags);                                                              \
   GType _value_type = G_VALUE_TYPE (_value);                                           \
   GTypeValueTable *_vtable = g_type_value_table_peek (_value_type);                    \
index 0391c89f68d7949f529c86aa612d8051a304663e..dde820b64186873bd28e774fc3a8a2df1f1f78c3 100644 (file)
@@ -462,7 +462,7 @@ g_value_types_init (void)  /* sync with gtype.c */
       value_lcopy_string,      /* lcopy_value */
     };
     info.value_table = &value_table;
-    type = g_type_register_fundamental (G_TYPE_STRING, "gstring", &info, &finfo, 0);
+    type = g_type_register_fundamental (G_TYPE_STRING, "gchararray", &info, &finfo, 0);
     g_assert (type == G_TYPE_STRING);
   }
 
@@ -743,19 +743,19 @@ g_strdup_value_contents (const GValue *value)
   else if (g_value_type_transformable (G_VALUE_TYPE (value), G_TYPE_STRING))
     {
       GValue tmp_value = { 0, };
-      
+      gchar *s;
+
       g_value_init (&tmp_value, G_TYPE_STRING);
       g_value_transform (value, &tmp_value);
+      s = g_strescape (g_value_get_string (&tmp_value), NULL);
+      g_value_unset (&tmp_value);
       if (G_VALUE_HOLDS_ENUM (value) || G_VALUE_HOLDS_FLAGS (value))
        contents = g_strdup_printf ("((%s) %s)",
                                    g_type_name (G_VALUE_TYPE (value)),
-                                   g_value_get_string (&tmp_value));
+                                   s);
       else
-       {
-         src = g_value_get_string (&tmp_value);
-         contents = g_strdup (src ? src : "NULL");
-       }
-      g_value_unset (&tmp_value);
+       contents = g_strdup (s ? s : "NULL");
+      g_free (s);
     }
   else if (g_value_fits_pointer (value))
     {
index 8f9ac7d3b0f3a72caada34a1a8c58836a673fb5f..371c846b5f29f8c12c65fb24cd271b3fdbcee2fe 100644 (file)
@@ -88,6 +88,9 @@ void g_value_set_string_take_ownership                (GValue            *value,
                                                 gchar             *v_string);
 
 
+/* humpf, need a C representable type name for G_TYPE_STRING */
+typedef gchar* gchararray;
+
 
 G_END_DECLS
 
index 540aa39a9862aaac4163917262e94d148c99744a..cf73a04d4fd218abd1b470fe874a32d6638a407c 100644 (file)
@@ -184,7 +184,7 @@ g_scanner_new (const GScannerConfig *config_templ)
   scanner->max_parse_errors = 0;
   scanner->parse_errors        = 0;
   scanner->input_name = NULL;
-  scanner->derived_data = NULL;
+  g_datalist_init (&scanner->qdata);
   
   scanner->config = g_new0 (GScannerConfig, 1);
   
@@ -275,6 +275,7 @@ g_scanner_destroy (GScanner *scanner)
 {
   g_return_if_fail (scanner != NULL);
   
+  g_datalist_clear (&scanner->qdata);
   g_hash_table_foreach (scanner->symbol_table, 
                        g_scanner_destroy_symbol_table_entry, NULL);
   g_hash_table_destroy (scanner->symbol_table);
index f489745d7736b7a48be867e176778adf28eeef98..4b9a07cbea57a93d9db8ac5f5bd00259c80a4996 100644 (file)
@@ -168,8 +168,8 @@ struct      _GScanner
   /* name of input stream, featured by the default message handler */
   const gchar          *input_name;
   
-  /* data pointer for derived structures */
-  gpointer             derived_data;
+  /* quarked data */
+  GData                        *qdata;
   
   /* link into the scanner configuration */
   GScannerConfig       *config;
index 65c2c6cdb956fbb8aeb8fb00c7c97c1ed1a72a64..5577fb3265d9f35ba3994c7842e10084c0df2484 100644 (file)
--- a/gslist.c
+++ b/gslist.c
@@ -325,29 +325,54 @@ GSList*
 g_slist_remove (GSList        *list,
                gconstpointer  data)
 {
-  GSList *tmp;
-  GSList *prev;
+  GSList *tmp, *prev = NULL;
 
-  prev = NULL;
   tmp = list;
-
   while (tmp)
     {
       if (tmp->data == data)
        {
          if (prev)
            prev->next = tmp->next;
-         if (list == tmp)
-           list = list->next;
-
-         tmp->next = NULL;
-         g_slist_free (tmp);
+         else
+           list = tmp->next;
 
+         g_slist_free_1 (tmp);
          break;
        }
-
       prev = tmp;
-      tmp = tmp->next;
+      tmp = prev->next;
+    }
+
+  return list;
+}
+
+GSList*
+g_slist_remove_all (GSList        *list,
+                   gconstpointer  data)
+{
+  GSList *tmp, *prev = NULL;
+
+  tmp = list;
+  while (tmp)
+    {
+      if (tmp->data == data)
+       {
+         GSList *next = tmp->next;
+
+         if (prev)
+           prev->next = next;
+         else
+           list = next;
+         
+         g_slist_free_1 (tmp);
+         tmp = next;
+       }
+      else
+       {
+         prev = tmp;
+         tmp = prev->next;
+       }
     }
 
   return list;
index 8d94b2c075975725c22bc907089402f32eab9d29..00d3fc336990e491488085d74c48f2e9cb38d9af 100644 (file)
--- a/gslist.h
+++ b/gslist.h
@@ -63,6 +63,8 @@ GSList*  g_slist_concat         (GSList           *list1,
                                 GSList           *list2);
 GSList*  g_slist_remove         (GSList           *list,
                                 gconstpointer     data);
+GSList*  g_slist_remove_all     (GSList           *list,
+                                gconstpointer     data);
 GSList*  g_slist_remove_link    (GSList           *list,
                                 GSList           *link);
 GSList*  g_slist_delete_link    (GSList           *list,
index 29c4de81c9ca73f200e9fd8e846ee595c0d73516..eec6fa42a10a89bba0950cae926585b315f64b36 100644 (file)
--- a/gtypes.h
+++ b/gtypes.h
@@ -43,7 +43,6 @@ typedef short  gshort;
 typedef long   glong;
 typedef int    gint;
 typedef gint   gboolean;
-typedef gchar* gstring;
 
 typedef unsigned char   guchar;
 typedef unsigned short  gushort;