Nagios
4.4.5
Dev docs for Nagios core and neb-module hackers
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
lib
fanout.h
Go to the documentation of this file.
1
#ifndef LIBNAGIOS_FANOUT_H_INCLUDED
2
#define LIBNAGIOS_FANOUT_H_INCLUDED
3
#include "
lnag-utils.h
"
4
5
/**
6
* @file fanout.h
7
* @brief Simple fanout table implementation
8
*
9
* Fanouts are useful to hold short-lived integer-indexed data where
10
* the keyspan between smallest and largest key can be too large and
11
* change too often for it to be practical to maintain a growing array.
12
* If you think of it as a hash-table optimized for unsigned longs you've
13
* got the right idea.
14
*
15
* @{
16
*/
17
18
NAGIOS_BEGIN_DECL
19
20
/** Primary (opaque) type for this api */
21
typedef
struct
fanout_table
fanout_table
;
22
23
/**
24
* Create a fanout table
25
* @param[in] size The size of the table. Preferably a power of 2
26
* @return Pointer to a newly created table
27
*/
28
extern
fanout_table
*
fanout_create
(
unsigned
long
size);
29
30
/**
31
* Destroy a fanout table, with optional destructor.
32
* This function will iterate over all the entries in the fanout
33
* table and remove them, one by one. If 'destructor' is not NULL,
34
* it will be called on each and every object in the table. Note that
35
* 'free' is a valid destructor.
36
*
37
* @param[in] t The fanout table to destroy
38
* @param[in] destructor Function to call on data pointers in table
39
*/
40
extern
void
fanout_destroy
(
fanout_table
*t,
void
(*destructor)(
void
*));
41
42
/**
43
* Return a pointer from the fanout table t
44
*
45
* @param[in] t table to fetch from
46
* @param[in] key key to fetch
47
* @return NULL on errors; Pointer to data on success
48
*/
49
extern
void
*
fanout_get
(
fanout_table
*t,
unsigned
long
key);
50
51
/**
52
* Add an entry to the fanout table.
53
* Note that we don't check if the key is unique. If it isn't,
54
* fanout_remove() will remove the latest added first.
55
*
56
* @param[in] t fanout table to add to
57
* @param[in] key Key for this entry
58
* @param[in] data Data to add. Must not be NULL
59
* @return 0 on success, -1 on errors
60
*/
61
extern
int
fanout_add
(
fanout_table
*t,
unsigned
long
key,
void
*data);
62
63
/**
64
* Remove an entry from the fanout table and return its data.
65
*
66
* @param[in] t fanout table to look in
67
* @param[in] key The key whose data we should locate
68
* @return Pointer to the data stored on success; NULL on errors
69
*/
70
extern
void
*
fanout_remove
(
fanout_table
*t,
unsigned
long
key);
71
NAGIOS_END_DECL
72
/** @} */
73
#endif
Generated on Tue Oct 8 2019 00:17:26 for Nagios by
1.8.3.1