libnl  3.2.24-rc1
Hashtable

Functions

nl_hash_table_tnl_hash_table_alloc (int size)
 Allocate hashtable. More...
 
void nl_hash_table_free (nl_hash_table_t *ht)
 Free hashtable including all nodes. More...
 
struct nl_object * nl_hash_table_lookup (nl_hash_table_t *ht, struct nl_object *obj)
 Lookup identical object in hashtable. More...
 
int nl_hash_table_add (nl_hash_table_t *ht, struct nl_object *obj)
 Add object to hashtable. More...
 
int nl_hash_table_del (nl_hash_table_t *ht, struct nl_object *obj)
 Remove object from hashtable. More...
 
uint32_t nl_hash (void *k, size_t length, uint32_t initval)
 

Detailed Description

Function Documentation

nl_hash_table_t* nl_hash_table_alloc ( int  size)

Allocate hashtable.

Parameters
sizeSize of hashtable in number of elements
Returns
Allocated hashtable or NULL.

Definition at line 29 of file hashtable.c.

Referenced by nl_cache_alloc().

+ Here is the caller graph for this function:

void nl_hash_table_free ( nl_hash_table_t ht)

Free hashtable including all nodes.

Parameters
htHashtable
Note
Reference counter of all objects in the hashtable will be decremented.

Definition at line 56 of file hashtable.c.

References nl_object_put().

+ Here is the call graph for this function:

struct nl_object* nl_hash_table_lookup ( nl_hash_table_t ht,
struct nl_object *  obj 
)
read

Lookup identical object in hashtable.

Parameters
htHashtable
objObject to lookup

Generates hashkey for obj and traverses the corresponding chain calling nl_object_identical() on each trying to find a match.

Returns
Pointer to object if match was found or NULL.

Definition at line 86 of file hashtable.c.

References nl_object_identical(), and nl_object_keygen().

+ Here is the call graph for this function:

int nl_hash_table_add ( nl_hash_table_t ht,
struct nl_object *  obj 
)

Add object to hashtable.

Parameters
htHashtable
objObject to add

Adds obj to the hashtable. Object type must support hashing, otherwise all objects will be added to the chain 0.

Note
The reference counter of the object is incremented.
Returns
0 on success or a negative error code
Return values
-NLE_EXISTIdentical object already present in hashtable

Definition at line 117 of file hashtable.c.

References nl_object_get(), nl_object_identical(), and nl_object_keygen().

+ Here is the call graph for this function:

int nl_hash_table_del ( nl_hash_table_t ht,
struct nl_object *  obj 
)

Remove object from hashtable.

Parameters
htHashtable
objObject to remove

Remove obj from hashtable if it exists.

Note
Reference counter of object will be decremented.
Returns
0 on success or a negative error code.
Return values
-NLE_OBJ_NOTFOUNDObject not present in hashtable.

Definition at line 161 of file hashtable.c.

References nl_object_identical(), nl_object_keygen(), and nl_object_put().

Referenced by nl_cache_remove().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: