Commit 1c4b0662 authored by David Zeuthen's avatar David Zeuthen
Browse files

ensure object is first in the list/hash iterator callback functions

This is useful for passing free / unref functions in.
parent ea980bee
......@@ -330,7 +330,7 @@ kit_hash_foreach (KitHash *hash, KitHashForeachFunc cb, void *user_data)
KitHashNode *node;
for (node = hash->top_nodes[n]; node != NULL; node = node->next) {
if (cb (hash, node->key, node->value, user_data))
if (cb (node->key, node->value, user_data, hash))
return TRUE;
}
}
......@@ -370,7 +370,7 @@ kit_hash_foreach_remove (KitHash *hash, KitHashForeachFunc cb, void *user_data)
for (node = hash->top_nodes[n]; node != NULL; node = node_next) {
node_next = node->next;
if (cb (hash, node->key, node->value, user_data)) {
if (cb (node->key, node->value, user_data, hash)) {
if (hash->key_destroy_func != NULL)
hash->key_destroy_func (node->key);
......@@ -472,7 +472,7 @@ kit_hash_str_copy (const void *p)
#ifdef KIT_BUILD_TESTS
static kit_bool_t
_it1 (KitHash *hash, void *key, void *value, void *user_data)
_it1 (void *key, void *value, void *user_data, KitHash *hash)
{
int *count = (int *) user_data;
*count += 1;
......@@ -480,7 +480,7 @@ _it1 (KitHash *hash, void *key, void *value, void *user_data)
}
static kit_bool_t
_it2 (KitHash *hash, void *key, void *value, void *user_data)
_it2 (void *key, void *value, void *user_data, KitHash *hash)
{
int *count = (int *) user_data;
*count += 1;
......@@ -488,7 +488,7 @@ _it2 (KitHash *hash, void *key, void *value, void *user_data)
}
static kit_bool_t
_it_sum (KitHash *hash, void *key, void *value, void *user_data)
_it_sum (void *key, void *value, void *user_data, KitHash *hash)
{
int *count = (int *) user_data;
*count += (int) value;
......@@ -496,7 +496,7 @@ _it_sum (KitHash *hash, void *key, void *value, void *user_data)
}
static kit_bool_t
_it_rem (KitHash *hash, void *key, void *value, void *user_data)
_it_rem (void *key, void *value, void *user_data, KitHash *hash)
{
if (strlen ((char *) key) > 4)
return TRUE;
......
......@@ -96,19 +96,19 @@ typedef void *(*KitCopyFunc) (const void *p);
/**
* KitHashForeachFunc:
* @hash: the hash table
* @key: key
* @value: value
* @user_data: user data passed to kit_hash_foreach()
* @hash: the hash table
*
* Type signature for callback function used in kit_hash_foreach().
*
* Returns: Return #TRUE to short-circuit, e.g. stop the iteration.
*/
typedef kit_bool_t (*KitHashForeachFunc) (KitHash *hash,
void *key,
typedef kit_bool_t (*KitHashForeachFunc) (void *key,
void *value,
void *user_data);
void *user_data,
KitHash *hash);
KitHash *kit_hash_new (KitHashFunc hash_func,
......
......@@ -232,7 +232,7 @@ kit_list_foreach (KitList *list, KitListForeachFunc func, void *user_data)
kit_return_val_if_fail (func != NULL, FALSE);
for (l = list; l != NULL; l = l->next) {
if (func (list, l->data, user_data))
if (func (l->data, user_data, list))
return TRUE;
}
......@@ -248,7 +248,7 @@ typedef struct {
} _Closure;
static kit_bool_t
_sum (KitList *list, void *data, void *user_data)
_sum (void *data, void *user_data, KitList *list)
{
_Closure *c = (_Closure*) user_data;
......@@ -259,7 +259,7 @@ _sum (KitList *list, void *data, void *user_data)
}
static kit_bool_t
_sum2 (KitList *list, void *data, void *user_data)
_sum2 (void *data, void *user_data, KitList *list)
{
_Closure *c = (_Closure*) user_data;
......
......@@ -57,17 +57,17 @@ struct _KitList {
/**
* KitListForeachFunc:
* @list: the list
* @data: data of link entry
* @user_data: user data passed to kit_list_foreach()
* @list: the list
*
* Type signature for callback function used in kit_list_foreach().
*
* Returns: Return #TRUE to short-circuit, e.g. stop the iteration.
*/
typedef kit_bool_t (*KitListForeachFunc) (KitList *list,
void *data,
void *user_data);
typedef kit_bool_t (*KitListForeachFunc) (void *data,
void *user_data,
KitList *list);
KitList *kit_list_append (KitList *list, void *data);
KitList *kit_list_prepend (KitList *list, void *data);
......
......@@ -774,7 +774,7 @@ out:
}
static kit_bool_t
_free_elem_in_list (KitList *list, void *data, void *user_data)
_free_elem_in_list (void *data, void *user_data, KitList *list)
{
kit_free (data);
return FALSE;
......@@ -1161,7 +1161,7 @@ polkit_tracker_init (PolKitTracker *pk_tracker)
/*--------------------------------------------------------------------------------------------------------------*/
static void
_set_session_inactive_iter (KitHash *hash, void *key, PolKitCaller *caller, const char *session_objpath)
_set_session_inactive_iter (void *key, PolKitCaller *caller, const char *session_objpath, KitHash *hash)
{
char *objpath;
PolKitSession *session;
......@@ -1175,7 +1175,7 @@ _set_session_inactive_iter (KitHash *hash, void *key, PolKitCaller *caller, cons
}
static void
_set_session_active_iter (KitHash *hash, void *key, PolKitCaller *caller, const char *session_objpath)
_set_session_active_iter (void *key, PolKitCaller *caller, const char *session_objpath, KitHash *hash)
{
char *objpath;
PolKitSession *session;
......@@ -1199,7 +1199,7 @@ _update_session_is_active (PolKitTracker *pk_tracker, const char *session_objpat
/*--------------------------------------------------------------------------------------------------------------*/
static kit_bool_t
_remove_caller_by_session_iter (KitHash *hash, void *key, PolKitCaller *caller, const char *session_objpath)
_remove_caller_by_session_iter (void *key, PolKitCaller *caller, const char *session_objpath, KitHash *hash)
{
char *objpath;
PolKitSession *session;
......@@ -1223,7 +1223,7 @@ _remove_caller_by_session (PolKitTracker *pk_tracker, const char *session_objpat
/*--------------------------------------------------------------------------------------------------------------*/
static kit_bool_t
_remove_caller_by_dbus_name_iter (KitHash *hash, void *key, PolKitCaller *caller, const char *dbus_name)
_remove_caller_by_dbus_name_iter (void *key, PolKitCaller *caller, const char *dbus_name, KitHash *hash)
{
char *name;
if (!polkit_caller_get_dbus_name (caller, &name))
......
......@@ -77,7 +77,7 @@ struct _PolKitAuthorizationDB;
/* PolKitAuthorizationDB structure is defined in polkit/polkit-private.h */
static kit_bool_t
clear_auth (KitList *list, void *data, void *user_data)
clear_auth (void *data, void *user_data, KitList *list)
{
PolKitAuthorization *auth = (PolKitAuthorization *) data;
polkit_authorization_unref (auth);
......
......@@ -558,10 +558,10 @@ typedef struct {
} _AnnotationsClosure;
static polkit_bool_t
_annotations_cb (KitHash *hash,
void *key,
_annotations_cb (void *key,
void *value,
void *user_data)
void *user_data,
KitHash *hash)
{
_AnnotationsClosure *closure = user_data;
return closure->cb (closure->pfe, (const char *) key, (const char *) value, closure->user_data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment