mirror of
https://github.com/openvswitch/ovs
synced 2025-09-04 08:15:25 +00:00
shash: New function shash_find_and_delete().
This commit is contained in:
13
lib/shash.c
13
lib/shash.c
@@ -100,6 +100,19 @@ shash_find_data(const struct shash *sh, const char *name)
|
|||||||
return node ? node->data : NULL;
|
return node ? node->data : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
shash_find_and_delete(struct shash *sh, const char *name)
|
||||||
|
{
|
||||||
|
struct shash_node *node = shash_find(sh, name);
|
||||||
|
if (node) {
|
||||||
|
void *data = node->data;
|
||||||
|
shash_delete(sh, node);
|
||||||
|
return data;
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct shash_node *
|
struct shash_node *
|
||||||
shash_first(const struct shash *shash)
|
shash_first(const struct shash *shash)
|
||||||
{
|
{
|
||||||
|
@@ -46,6 +46,7 @@ struct shash_node *shash_add(struct shash *, const char *, void *);
|
|||||||
void shash_delete(struct shash *, struct shash_node *);
|
void shash_delete(struct shash *, struct shash_node *);
|
||||||
struct shash_node *shash_find(const struct shash *, const char *);
|
struct shash_node *shash_find(const struct shash *, const char *);
|
||||||
void *shash_find_data(const struct shash *, const char *);
|
void *shash_find_data(const struct shash *, const char *);
|
||||||
|
void *shash_find_and_delete(struct shash *, const char *);
|
||||||
struct shash_node *shash_first(const struct shash *);
|
struct shash_node *shash_first(const struct shash *);
|
||||||
|
|
||||||
#endif /* shash.h */
|
#endif /* shash.h */
|
||||||
|
Reference in New Issue
Block a user