+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
+Wed Oct 7 05:31:24 1998 Tim Janik <timj@gtk.org>
+
+ * glib.h:
+ removed the #pragma } statement after extern "C" {. use
+ (c-set-offset 'inextern-lang 0) to fixup emacs cc-mode indentation.
+
+ * glib.h:
+ * ghook.c: API and code cleanups. changed the G_HOOK_ACTIVE and
+ G_HOOK_IN_CALL enum vals to G_HOOK_FLAG_ACTIVE and G_HOOK_FLAG_IN_CALL.
+ changed the G_HOOK_IS_ACTIVE() and G_HOOK_IS_IN_CALL() macros to
+ G_HOOK_ACTIVE() and G_HOOK_IN_CALL().
+ fixed the g_hook_find* functions, so they iterate over non-active
+ hooks as well.
+ (g_hook_first_valid):
+ (g_hook_next_valid): added an extra argument gboolean may_be_in_call,
+ which indicates whether G_HOOK_IN_CALL() hooks are considered valid
+ or not. these two functions are meant as iterators for the hook list
+ invocation, so they need to a) provide functionality to implement
+ may_recurse bahaviour and b) only walk active hooks.
+
Tue Oct 6 14:29:47 1998 Tim Janik <timj@gtk.org>
* gmem.c (g_malloc0): fixed memory offsett when ENABLE_MEM_CHECK is
else
do
{
- register GHook *tmp;
+ GHook *tmp;
g_hook_ref (hook_list, hook);
g_hook_destroy_link (hook_list, hook);
hook->data = NULL;
hook->next = NULL;
hook->prev = NULL;
- hook->flags = G_HOOK_ACTIVE;
+ hook->flags = G_HOOK_FLAG_ACTIVE;
hook->ref_count = 0;
hook->hook_id = 0;
hook->func = NULL;
if (hook->hook_id)
{
hook->hook_id = 0;
- hook->flags &= ~G_HOOK_ACTIVE;
+ hook->flags &= ~G_HOOK_FLAG_ACTIVE;
if (hook->destroy)
{
- register GDestroyNotify destroy;
+ GDestroyNotify destroy;
destroy = hook->destroy;
hook->destroy = NULL;
if (!hook->ref_count)
{
g_return_if_fail (hook->hook_id == 0);
- g_return_if_fail (!G_HOOK_IS_IN_CALL (hook));
+ g_return_if_fail (!G_HOOK_IN_CALL (hook));
if (hook->prev)
hook->prev->next = hook->next;
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
- register GHookFunc func;
+ GHook *tmp;
+ GHookFunc func;
gboolean was_in_call;
g_hook_ref (hook_list, hook);
func = hook->func;
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
func (hook->data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
- register GHookCheckFunc func;
+ GHook *tmp;
+ GHookCheckFunc func;
gboolean was_in_call;
- register gboolean need_destroy;
+ gboolean need_destroy;
g_hook_ref (hook_list, hook);
func = hook->func;
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
need_destroy = !func (hook->data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (marshaller != NULL);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
+ GHook *tmp;
gboolean was_in_call;
g_hook_ref (hook_list, hook);
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
marshaller (hook, data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
}
GHook*
-g_hook_first_valid (GHookList *hook_list)
+g_hook_first_valid (GHookList *hook_list,
+ gboolean may_be_in_call)
{
g_return_val_if_fail (hook_list != NULL, NULL);
hook = hook_list->hooks;
if (hook)
{
- if (G_HOOK_IS_VALID (hook))
+ if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
else
- return g_hook_next_valid (hook);
+ return g_hook_next_valid (hook, may_be_in_call);
}
}
}
GHook*
-g_hook_next_valid (GHook *hook)
+g_hook_next_valid (GHook *hook,
+ gboolean may_be_in_call)
{
if (!hook)
return NULL;
hook = hook->next;
while (hook)
{
- if (G_HOOK_IS_VALID (hook))
+ if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
hook = hook->next;
}
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- register GHook *tmp;
+ GHook *tmp;
+
+ /* test only non-destroyed hooks */
+ if (!hook->hook_id)
+ {
+ hook = hook->next;
+ continue;
+ }
g_hook_ref (hook_list, hook);
- if (func (hook, data) && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ if (func (hook, data) && hook->hook_id && (!need_valids || G_HOOK_ACTIVE (hook)))
{
g_hook_unref (hook_list, hook);
return hook;
}
- tmp = g_hook_next_valid (hook);
+
+ tmp = hook->next;
g_hook_unref (hook_list, hook);
hook = tmp;
}
gboolean need_valids,
gpointer data)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->data == data && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->data == data &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
gboolean need_valids,
gpointer func)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->func == func && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->func == func &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
gpointer func,
gpointer data)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->data == data && hook->func == func && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->data == data &&
+ hook->func == func &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
g_return_if_fail (G_HOOK_IS_UNLINKED (hook));
g_return_if_fail (hook->func != NULL);
g_return_if_fail (func != NULL);
-
- sibling = g_hook_first_valid (hook_list);
+
+ /* first non-destroyed hook */
+ sibling = hook_list->hooks;
+ while (sibling && !sibling->hook_id)
+ sibling = sibling->next;
while (sibling)
{
- register GHook *tmp;
+ GHook *tmp;
g_hook_ref (hook_list, sibling);
if (func (hook, sibling) <= 0 && sibling->hook_id)
g_hook_unref (hook_list, sibling);
break;
}
- tmp = g_hook_next_valid (sibling);
+
+ /* next non-destroyed hook */
+ tmp = sibling->next;
+ while (tmp && !tmp->hook_id)
+ tmp = tmp->next;
+
g_hook_unref (hook_list, sibling);
sibling = tmp;
}
#endif /* HAVE_VALUES_H */
-/* the #pragma } statment is used to fix up emacs' c-mode which gets
- * confused by extern "C" {. the ansi standard says that compilers
- * have to ignore #pragma directives that they don't know about,
- * so we should be save in using this.
- */
#ifdef __cplusplus
extern "C" {
-#pragma }
#endif /* __cplusplus */
#define G_HOOK_FLAG_USER_SHIFT (4)
typedef enum
{
- G_HOOK_ACTIVE = 1 << 0,
- G_HOOK_IN_CALL = 1 << 1,
+ G_HOOK_FLAG_ACTIVE = 1 << 0,
+ G_HOOK_FLAG_IN_CALL = 1 << 1,
G_HOOK_FLAG_MASK = 0x0f
} GHookFlagMask;
GDestroyNotify destroy;
};
-#define G_HOOK_IS_ACTIVE(hook) ((((GHook*) hook)->flags & \
- G_HOOK_ACTIVE) != 0)
-#define G_HOOK_IS_IN_CALL(hook) ((((GHook*) hook)->flags & \
- G_HOOK_IN_CALL) != 0)
+#define G_HOOK_ACTIVE(hook) ((((GHook*) hook)->flags & \
+ G_HOOK_FLAG_ACTIVE) != 0)
+#define G_HOOK_IN_CALL(hook) ((((GHook*) hook)->flags & \
+ G_HOOK_FLAG_IN_CALL) != 0)
#define G_HOOK_IS_VALID(hook) (((GHook*) hook)->hook_id != 0 && \
- G_HOOK_IS_ACTIVE (hook))
+ G_HOOK_ACTIVE (hook))
#define G_HOOK_IS_UNLINKED(hook) (((GHook*) hook)->next == NULL && \
((GHook*) hook)->prev == NULL && \
((GHook*) hook)->hook_id == 0 && \
gboolean need_valids,
gpointer func,
gpointer data);
-GHook* g_hook_first_valid (GHookList *hook_list);
-GHook* g_hook_next_valid (GHook *hook);
+GHook* g_hook_first_valid (GHookList *hook_list,
+ gboolean may_be_in_call);
+GHook* g_hook_next_valid (GHook *hook,
+ gboolean may_be_in_call);
+
+/* GHookCompareFunc implementation to insert hooks sorted by their id */
gint g_hook_compare_ids (GHook *new_hook,
GHook *sibling);
else
do
{
- register GHook *tmp;
+ GHook *tmp;
g_hook_ref (hook_list, hook);
g_hook_destroy_link (hook_list, hook);
hook->data = NULL;
hook->next = NULL;
hook->prev = NULL;
- hook->flags = G_HOOK_ACTIVE;
+ hook->flags = G_HOOK_FLAG_ACTIVE;
hook->ref_count = 0;
hook->hook_id = 0;
hook->func = NULL;
if (hook->hook_id)
{
hook->hook_id = 0;
- hook->flags &= ~G_HOOK_ACTIVE;
+ hook->flags &= ~G_HOOK_FLAG_ACTIVE;
if (hook->destroy)
{
- register GDestroyNotify destroy;
+ GDestroyNotify destroy;
destroy = hook->destroy;
hook->destroy = NULL;
if (!hook->ref_count)
{
g_return_if_fail (hook->hook_id == 0);
- g_return_if_fail (!G_HOOK_IS_IN_CALL (hook));
+ g_return_if_fail (!G_HOOK_IN_CALL (hook));
if (hook->prev)
hook->prev->next = hook->next;
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
- register GHookFunc func;
+ GHook *tmp;
+ GHookFunc func;
gboolean was_in_call;
g_hook_ref (hook_list, hook);
func = hook->func;
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
func (hook->data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
g_return_if_fail (hook_list != NULL);
g_return_if_fail (hook_list->is_setup);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
- register GHookCheckFunc func;
+ GHook *tmp;
+ GHookCheckFunc func;
gboolean was_in_call;
- register gboolean need_destroy;
+ gboolean need_destroy;
g_hook_ref (hook_list, hook);
func = hook->func;
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
need_destroy = !func (hook->data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
if (need_destroy)
g_hook_destroy_link (hook_list, hook);
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
g_return_if_fail (hook_list->is_setup);
g_return_if_fail (marshaller != NULL);
- if (may_recurse)
- hook = g_hook_first_valid (hook_list);
- else
- do
- hook = g_hook_first_valid (hook_list);
- while (hook && G_HOOK_IS_IN_CALL (hook));
+ hook = g_hook_first_valid (hook_list, may_recurse);
while (hook)
{
- register GHook *tmp;
+ GHook *tmp;
gboolean was_in_call;
g_hook_ref (hook_list, hook);
- was_in_call = G_HOOK_IS_IN_CALL (hook);
- hook->flags |= G_HOOK_IN_CALL;
+ was_in_call = G_HOOK_IN_CALL (hook);
+ hook->flags |= G_HOOK_FLAG_IN_CALL;
marshaller (hook, data);
if (!was_in_call)
- hook->flags &= ~G_HOOK_IN_CALL;
+ hook->flags &= ~G_HOOK_FLAG_IN_CALL;
- if (may_recurse)
- tmp = g_hook_next_valid (hook);
- else
- do
- tmp = g_hook_next_valid (hook);
- while (tmp && G_HOOK_IS_IN_CALL (tmp));
+ tmp = g_hook_next_valid (hook, may_recurse);
g_hook_unref (hook_list, hook);
hook = tmp;
}
GHook*
-g_hook_first_valid (GHookList *hook_list)
+g_hook_first_valid (GHookList *hook_list,
+ gboolean may_be_in_call)
{
g_return_val_if_fail (hook_list != NULL, NULL);
hook = hook_list->hooks;
if (hook)
{
- if (G_HOOK_IS_VALID (hook))
+ if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
else
- return g_hook_next_valid (hook);
+ return g_hook_next_valid (hook, may_be_in_call);
}
}
}
GHook*
-g_hook_next_valid (GHook *hook)
+g_hook_next_valid (GHook *hook,
+ gboolean may_be_in_call)
{
if (!hook)
return NULL;
hook = hook->next;
while (hook)
{
- if (G_HOOK_IS_VALID (hook))
+ if (G_HOOK_IS_VALID (hook) && (may_be_in_call || !G_HOOK_IN_CALL (hook)))
return hook;
hook = hook->next;
}
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- register GHook *tmp;
+ GHook *tmp;
+
+ /* test only non-destroyed hooks */
+ if (!hook->hook_id)
+ {
+ hook = hook->next;
+ continue;
+ }
g_hook_ref (hook_list, hook);
- if (func (hook, data) && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ if (func (hook, data) && hook->hook_id && (!need_valids || G_HOOK_ACTIVE (hook)))
{
g_hook_unref (hook_list, hook);
return hook;
}
- tmp = g_hook_next_valid (hook);
+
+ tmp = hook->next;
g_hook_unref (hook_list, hook);
hook = tmp;
}
gboolean need_valids,
gpointer data)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->data == data && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->data == data &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
gboolean need_valids,
gpointer func)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->func == func && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->func == func &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
gpointer func,
gpointer data)
{
- register GHook *hook;
+ GHook *hook;
g_return_val_if_fail (hook_list != NULL, NULL);
g_return_val_if_fail (func != NULL, NULL);
- hook = g_hook_first_valid (hook_list);
+ hook = hook_list->hooks;
while (hook)
{
- if (hook->data == data && hook->func == func && hook->hook_id && (!need_valids || G_HOOK_IS_ACTIVE (hook)))
+ /* test only non-destroyed hooks */
+ if (hook->data == data &&
+ hook->func == func &&
+ hook->hook_id &&
+ (!need_valids || G_HOOK_ACTIVE (hook)))
return hook;
-
- hook = g_hook_next_valid (hook);
+
+ hook = hook->next;
}
return NULL;
g_return_if_fail (G_HOOK_IS_UNLINKED (hook));
g_return_if_fail (hook->func != NULL);
g_return_if_fail (func != NULL);
-
- sibling = g_hook_first_valid (hook_list);
+
+ /* first non-destroyed hook */
+ sibling = hook_list->hooks;
+ while (sibling && !sibling->hook_id)
+ sibling = sibling->next;
while (sibling)
{
- register GHook *tmp;
+ GHook *tmp;
g_hook_ref (hook_list, sibling);
if (func (hook, sibling) <= 0 && sibling->hook_id)
g_hook_unref (hook_list, sibling);
break;
}
- tmp = g_hook_next_valid (sibling);
+
+ /* next non-destroyed hook */
+ tmp = sibling->next;
+ while (tmp && !tmp->hook_id)
+ tmp = tmp->next;
+
g_hook_unref (hook_list, sibling);
sibling = tmp;
}
#endif /* HAVE_VALUES_H */
-/* the #pragma } statment is used to fix up emacs' c-mode which gets
- * confused by extern "C" {. the ansi standard says that compilers
- * have to ignore #pragma directives that they don't know about,
- * so we should be save in using this.
- */
#ifdef __cplusplus
extern "C" {
-#pragma }
#endif /* __cplusplus */
#define G_HOOK_FLAG_USER_SHIFT (4)
typedef enum
{
- G_HOOK_ACTIVE = 1 << 0,
- G_HOOK_IN_CALL = 1 << 1,
+ G_HOOK_FLAG_ACTIVE = 1 << 0,
+ G_HOOK_FLAG_IN_CALL = 1 << 1,
G_HOOK_FLAG_MASK = 0x0f
} GHookFlagMask;
GDestroyNotify destroy;
};
-#define G_HOOK_IS_ACTIVE(hook) ((((GHook*) hook)->flags & \
- G_HOOK_ACTIVE) != 0)
-#define G_HOOK_IS_IN_CALL(hook) ((((GHook*) hook)->flags & \
- G_HOOK_IN_CALL) != 0)
+#define G_HOOK_ACTIVE(hook) ((((GHook*) hook)->flags & \
+ G_HOOK_FLAG_ACTIVE) != 0)
+#define G_HOOK_IN_CALL(hook) ((((GHook*) hook)->flags & \
+ G_HOOK_FLAG_IN_CALL) != 0)
#define G_HOOK_IS_VALID(hook) (((GHook*) hook)->hook_id != 0 && \
- G_HOOK_IS_ACTIVE (hook))
+ G_HOOK_ACTIVE (hook))
#define G_HOOK_IS_UNLINKED(hook) (((GHook*) hook)->next == NULL && \
((GHook*) hook)->prev == NULL && \
((GHook*) hook)->hook_id == 0 && \
gboolean need_valids,
gpointer func,
gpointer data);
-GHook* g_hook_first_valid (GHookList *hook_list);
-GHook* g_hook_next_valid (GHook *hook);
+GHook* g_hook_first_valid (GHookList *hook_list,
+ gboolean may_be_in_call);
+GHook* g_hook_next_valid (GHook *hook,
+ gboolean may_be_in_call);
+
+/* GHookCompareFunc implementation to insert hooks sorted by their id */
gint g_hook_compare_ids (GHook *new_hook,
GHook *sibling);