Nagios
4.5.12
Dev docs for Nagios core and neb-module hackers
Toggle main menu visibility
Loading...
Searching...
No Matches
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
fanout_create
fanout_table * fanout_create(unsigned long size)
Create a fanout table.
fanout_table
typedefNAGIOS_BEGIN_DECL struct fanout_table fanout_table
Primary (opaque) type for this api.
Definition
fanout.h:21
fanout_get
void * fanout_get(fanout_table *t, unsigned long key)
Return a pointer from the fanout table t.
fanout_destroy
void fanout_destroy(fanout_table *t, void(*destructor)(void *))
Destroy a fanout table, with optional destructor.
fanout_add
int fanout_add(fanout_table *t, unsigned long key, void *data)
Add an entry to the fanout table.
fanout_remove
void * fanout_remove(fanout_table *t, unsigned long key)
Remove an entry from the fanout table and return its data.
lnag-utils.h
libnagios helper and compatibility macros that lack a "real" home.
NAGIOS_END_DECL
#define NAGIOS_END_DECL
C++ compatibility macro that avoid confusing indentation programs.
Definition
lnag-utils.h:32
NAGIOS_BEGIN_DECL
#define NAGIOS_BEGIN_DECL
C++ compatibility macro that avoids confusing indentation programs.
Definition
lnag-utils.h:30
lib
fanout.h
Generated by
1.17.0