mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-02 07:23:41 +02:00
removed archaic gpointer derived_data; relict and added a GData member
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.
This commit is contained in:
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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.
|
||||
|
@@ -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>.
|
||||
|
||||
|
@@ -43,7 +43,7 @@ handler function is declared by #GScannerMsgFunc.
|
||||
@max_parse_errors:
|
||||
@parse_errors:
|
||||
@input_name:
|
||||
@derived_data:
|
||||
@qdata:
|
||||
@config:
|
||||
@token:
|
||||
@value:
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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.
|
||||
|
@@ -24,6 +24,41 @@
|
||||
|
||||
|
||||
/* --- 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);
|
||||
|
@@ -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)
|
||||
|
28
glib/glist.c
28
glib/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)
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
28
glist.c
28
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)
|
||||
|
2
glist.h
2
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,
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -24,6 +24,41 @@
|
||||
|
||||
|
||||
/* --- 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);
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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),
|
||||
|
@@ -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 --- */
|
||||
|
@@ -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); \
|
||||
|
@@ -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))
|
||||
{
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
47
gslist.c
47
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;
|
||||
|
2
gslist.h
2
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,
|
||||
|
Reference in New Issue
Block a user