File: ptrmap.h

package info (click to toggle)
sparse 0.6.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,868 kB
  • sloc: ansic: 46,050; sh: 614; python: 301; perl: 293; makefile: 279
file content (28 lines) | stat: -rw-r--r-- 865 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef PTRMAP_H
#define PTRMAP_H

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);
void __ptrmap_update(struct ptrmap **mapp, void *key, void *val);
void *__ptrmap_lookup(struct ptrmap *map, void *key);

#endif