]> git.proxmox.com Git - ovs.git/blame - lib/shash.h
datapath-windows: Avoid BSOD when switch context is NULL
[ovs.git] / lib / shash.h
CommitLineData
064af421 1/*
e0edde6f 2 * Copyright (c) 2009, 2010, 2011 Nicira, Inc.
064af421 3 *
a14bc59f
BP
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
064af421 7 *
a14bc59f
BP
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
064af421
BP
15 */
16
17#ifndef SHASH_H
18#define SHASH_H 1
19
20#include "hmap.h"
21
fbfffdbb
BP
22#ifdef __cplusplus
23extern "C" {
24#endif
25
064af421
BP
26struct shash_node {
27 struct hmap_node node;
28 char *name;
29 void *data;
30};
31
32struct shash {
33 struct hmap map;
34};
35
36#define SHASH_INITIALIZER(SHASH) { HMAP_INITIALIZER(&(SHASH)->map) }
37
4e8e4213
BP
38#define SHASH_FOR_EACH(SHASH_NODE, SHASH) \
39 HMAP_FOR_EACH (SHASH_NODE, node, &(SHASH)->map)
fd30311c 40
4e8e4213
BP
41#define SHASH_FOR_EACH_SAFE(SHASH_NODE, NEXT, SHASH) \
42 HMAP_FOR_EACH_SAFE (SHASH_NODE, NEXT, node, &(SHASH)->map)
fd30311c 43
064af421
BP
44void shash_init(struct shash *);
45void shash_destroy(struct shash *);
a90b56b7 46void shash_destroy_free_data(struct shash *);
37e7f427 47void shash_swap(struct shash *, struct shash *);
baa8f41b 48void shash_moved(struct shash *);
064af421 49void shash_clear(struct shash *);
a90b56b7 50void shash_clear_free_data(struct shash *);
732dcb37 51bool shash_is_empty(const struct shash *);
c01da229 52size_t shash_count(const struct shash *);
55213fd5 53struct shash_node *shash_add(struct shash *, const char *, const void *);
ce5a3e38 54struct shash_node *shash_add_nocopy(struct shash *, char *, const void *);
76343538 55bool shash_add_once(struct shash *, const char *, const void *);
4a1ee6ae 56void shash_add_assert(struct shash *, const char *, const void *);
79903dd1 57void *shash_replace(struct shash *, const char *, const void *data);
064af421 58void shash_delete(struct shash *, struct shash_node *);
4f222648 59char *shash_steal(struct shash *, struct shash_node *);
064af421 60struct shash_node *shash_find(const struct shash *, const char *);
e74a239d 61struct shash_node *shash_find_len(const struct shash *, const char *, size_t);
064af421 62void *shash_find_data(const struct shash *, const char *);
837e8097 63void *shash_find_and_delete(struct shash *, const char *);
4a1ee6ae 64void *shash_find_and_delete_assert(struct shash *, const char *);
7efc68eb 65struct shash_node *shash_first(const struct shash *);
07423999 66const struct shash_node **shash_sort(const struct shash *);
37e7f427 67bool shash_equal_keys(const struct shash *, const struct shash *);
f2f7be86 68struct shash_node *shash_random_node(struct shash *);
064af421 69
fbfffdbb
BP
70#ifdef __cplusplus
71}
72#endif
73
064af421 74#endif /* shash.h */