diff options
author | Dan Williams <dcbw@redhat.com> | 2011-07-01 14:18:46 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-07-01 15:38:38 -0500 |
commit | c08279dff449a7f593a729fa798d2d4207b421fc (patch) | |
tree | caa836c354b869c253e2a381ffb148449583247c /src | |
parent | 937970f60c8e210b4f63b023670d6ab38e0cb277 (diff) | |
download | NetworkManager-c08279dff449a7f593a729fa798d2d4207b421fc.tar.gz |
core: add nm_auth_chain_steal_data()
New function for removing data from the auth chain without
destroying it.
Diffstat (limited to 'src')
-rw-r--r-- | src/nm-manager-auth.c | 31 | ||||
-rw-r--r-- | src/nm-manager-auth.h | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/nm-manager-auth.c b/src/nm-manager-auth.c index d6cc1b2c6c..beed65ab34 100644 --- a/src/nm-manager-auth.c +++ b/src/nm-manager-auth.c @@ -173,6 +173,37 @@ nm_auth_chain_get_data (NMAuthChain *self, const char *tag) return tmp ? tmp->data : NULL; } +/** + * nm_auth_chain_steal_data: + * @self: A #NMAuthChain. + * @tag: A "tag" uniquely identifying the data to steal. + * + * Removes the datum assocated with @tag from the chain's data associations, + * without invoking the association's destroy handler. The caller assumes + * ownership over the returned value. + * + * Returns: the datum originally associated with @tag + */ +gpointer +nm_auth_chain_steal_data (NMAuthChain *self, const char *tag) +{ + ChainData *tmp; + gpointer value = NULL; + + g_return_val_if_fail (self != NULL, NULL); + g_return_val_if_fail (tag != NULL, NULL); + + tmp = g_hash_table_lookup (self->data, tag); + if (tmp) { + g_hash_table_steal (self->data, tag); + value = tmp->data; + /* Make sure the destroy handler isn't called when freeing */ + tmp->destroy = NULL; + free_data (tmp); + } + return value; +} + void nm_auth_chain_set_data (NMAuthChain *self, const char *tag, diff --git a/src/nm-manager-auth.h b/src/nm-manager-auth.h index 321e04d605..15317c718d 100644 --- a/src/nm-manager-auth.h +++ b/src/nm-manager-auth.h @@ -70,6 +70,8 @@ NMAuthChain *nm_auth_chain_new_dbus_sender (const char *dbus_sender, gpointer nm_auth_chain_get_data (NMAuthChain *chain, const char *tag); +gpointer nm_auth_chain_steal_data (NMAuthChain *chain, const char *tag); + void nm_auth_chain_set_data (NMAuthChain *chain, const char *tag, gpointer data, |