diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-04-14 14:20:18 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-07-01 00:18:44 +0200 |
| commit | 017a4deba447a51d12cd397cd47f666ec20dc2e5 (patch) | |
| tree | a4cb0c2c197b9fceaf828b65b96fed139fa207c4 | |
| parent | 12ade83c58720c9e0c18789f5ea6078a9eec1505 (diff) | |
| download | sparse-dev-017a4deba447a51d12cd397cd47f666ec20dc2e5.tar.gz | |
ptrmap: add type-safe interface
Add the external, type-safe, API for the ptrmap implementation.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | ptrmap.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -3,6 +3,22 @@ struct ptrmap; +#define DECLARE_PTRMAP(name, ktype, vtype) \ + struct name ## _pair { ktype key; vtype val; }; \ + struct name { struct name ## _pair block[1]; }; \ + static inline \ + void name##_add(struct name **map, ktype k, vtype v) { \ + __ptrmap_add((struct ptrmap**)map, k, v); \ + } \ + static inline \ + void name##_update(struct name **map, ktype k, vtype v) { \ + __ptrmap_update((struct ptrmap**)map, k, v); \ + } \ + static inline \ + vtype name##_lookup(struct name *map, ktype k) { \ + vtype val = __ptrmap_lookup((struct ptrmap*)map, k); \ + return val; \ + } \ /* ptrmap.c */ void __ptrmap_add(struct ptrmap **mapp, void *key, void *val); |
