DTS Application Library
0.2.3
Application library containing referenced objects and interfaces to common libraries
|
Store references in and retrive from linked lists based on a hash. More...
Files | |
file | refobj.c |
Referenced Lockable Objects. | |
Data Structures | |
struct | blist_obj |
Entry in a bucket list. More... | |
struct | bucket_list |
Bucket list, hold hashed objects in buckets. More... | |
struct | bucket_loop |
Bucket iterator. More... | |
Typedefs | |
typedef int32_t(* | blisthash )(const void *, int) |
Callback used to calculate the hash of a structure. More... | |
typedef void(* | blist_cb )(void *, void *) |
This callback is run on each entry in a list. More... | |
Functions | |
void * | create_bucketlist (int bitmask, blisthash hash_function) |
int | addtobucket (struct bucket_list *blist, void *data) |
Add a reference to the bucketlist. More... | |
void | remove_bucket_item (struct bucket_list *blist, void *data) |
Remove and unreference a item from the list. More... | |
int | bucket_list_cnt (struct bucket_list *blist) |
Return number of items in the list. More... | |
void * | bucket_list_find_key (struct bucket_list *blist, const void *key) |
Find and return a reference to a item matching supplied key. More... | |
void | bucketlist_callback (struct bucket_list *blist, blist_cb callback, void *data2) |
Run a callback function on all items in the list. More... | |
struct bucket_loop * | init_bucket_loop (struct bucket_list *blist) |
Create a bucket list iterator to safely iterate the list. More... | |
void * | next_bucket_loop (struct bucket_loop *bloop) |
Return a reference to the next item in the list this could be the first item. More... | |
void | remove_bucket_loop (struct bucket_loop *bloop) |
Safely remove a item from a list while iterating in a loop. More... | |
Store references in and retrive from linked lists based on a hash.
Create a hashed bucket list.
A bucket list is a ref obj the "list" element is a array of "bucket" entries each has a hash the default is to hash the memory when there is no call back
bitmask | Number of buckets to create 2^bitmask. |
hash_function | Callback that returns the unique hash for a item this value must not change. |
typedef void(* blist_cb)(void *, void *) |
This callback is run on each entry in a list.
data | Reference held by the list. |
data2 | Reference to data supplied when calling bucketlist_callback. |
typedef int32_t(* blisthash)(const void *, int) |
int addtobucket | ( | struct bucket_list * | blist, |
void * | data | ||
) |
Add a reference to the bucketlist.
Create a entry in the list for reference obtained from data.
blist | Bucket list to add too. |
data | to obtain a reference too and add to the list. |
Definition at line 428 of file refobj.c.
References bucket_list::bucketbits, bucket_list::count, ref_obj::data, blist_obj::data, blist_obj::hash, bucket_list::list, bucket_list::locks, blist_obj::next, objlock(), objref(), objunlock(), objunref(), blist_obj::prev, refobj_offset, and bucket_list::version.
Referenced by add_radserver(), framework_mkthread(), process_config(), rfc6296_map_add(), and xslt_addparam().
int bucket_list_cnt | ( | struct bucket_list * | blist | ) |
Return number of items in the list.
blist | Bucket list to get count of. |
Definition at line 552 of file refobj.c.
References bucket_list::count, objlock(), and objunlock().
Referenced by add_radserver(), ldap_doadd(), and ldap_domodify().
void* bucket_list_find_key | ( | struct bucket_list * | blist, |
const void * | key | ||
) |
Find and return a reference to a item matching supplied key.
The key is supplied to the hash callback ad the data value and the key flag set. The hash for the object will be returned by the hash callback to find the item in the lists.
blist | Bucket list to search. |
key | Supplied to hash callback to find the item. |
Definition at line 572 of file refobj.c.
References bucket_list::bucketbits, ref_obj::data, blist_obj::data, blist_obj::hash, bucket_list::list, bucket_list::locks, objref(), and objunref().
Referenced by get_config_category(), get_config_entry(), get_config_file(), ldap_getattr(), ldap_getentry(), nfqueue_attach(), xml_getattr(), and xml_getnode().
void bucketlist_callback | ( | struct bucket_list * | blist, |
blist_cb | callback, | ||
void * | data2 | ||
) |
Run a callback function on all items in the list.
This will iterate safely through all items calling the callback with the item and the optional data supplied.
blist | Bucket list to iterate through. |
callback | Callback to call for each iteration. |
data2 | Data to be set as option to the callback. |
Definition at line 613 of file refobj.c.
References init_bucket_loop(), next_bucket_loop(), and objunref().
Referenced by config_cat_callback(), config_entry_callback(), config_file_callback(), and rfc6296_test().
void* create_bucketlist | ( | int | bitmask, |
blisthash | hash_function | ||
) |
Definition at line 356 of file refobj.c.
References bucket_list::bucketbits, and objalloc().
Referenced by add_radserver(), ldap_addinit(), ldap_modifyinit(), rfc6296_map_add(), socketserver(), startthreads(), xslt_clearparam(), and xslt_open().
struct bucket_loop* init_bucket_loop | ( | struct bucket_list * | blist | ) |
Create a bucket list iterator to safely iterate the list.
blist | Bucket list to create iterator for. |
Definition at line 640 of file refobj.c.
References bucket_loop::blist, bucket_loop::bucket, blist_obj::hash, bucket_loop::head, bucket_loop::head_hash, bucket_list::list, bucket_list::locks, objalloc(), objref(), bucket_list::version, and bucket_loop::version.
Referenced by bucketlist_callback(), get_category_loop(), ldap_doadd(), and ldap_domodify().
void* next_bucket_loop | ( | struct bucket_loop * | bloop | ) |
Return a reference to the next item in the list this could be the first item.
bloop | Bucket iterator |
Definition at line 662 of file refobj.c.
References bucket_loop::blist, bucket_loop::bucket, bucket_list::bucketbits, bucket_loop::cur, bucket_loop::cur_hash, ref_obj::data, blist_obj::data, blist_obj::hash, bucket_loop::head, bucket_loop::head_hash, bucket_list::list, bucket_list::locks, blist_obj::next, objref(), blist_obj::prev, bucket_list::version, and bucket_loop::version.
Referenced by bucketlist_callback(), get_category_next(), ldap_doadd(), and ldap_domodify().
void remove_bucket_item | ( | struct bucket_list * | blist, |
void * | data | ||
) |
Remove and unreference a item from the list.
blist | Bucket list to remove item from. |
data | Reference to be removed and unreferenced. |
Definition at line 517 of file refobj.c.
References bucket_list::bucketbits, bucket_list::count, ref_obj::data, blist_obj::data, blist_obj::hash, bucket_list::list, bucket_list::locks, blist_obj::next, objlock(), objunlock(), objunref(), blist_obj::prev, and bucket_list::version.
Referenced by ldap_unref_attr(), and ldap_unref_entry().
void remove_bucket_loop | ( | struct bucket_loop * | bloop | ) |
Safely remove a item from a list while iterating in a loop.
While traversing the bucket list its best to use this function to remove a reference and delete it from the list.
bloop | Bucket iterator. |
Definition at line 710 of file refobj.c.
References bucket_loop::blist, bucket_loop::bucket, bucket_list::bucketbits, bucket_list::count, bucket_loop::cur, bucket_loop::cur_hash, ref_obj::data, blist_obj::data, blist_obj::hash, bucket_list::list, bucket_list::locks, blist_obj::next, objlock(), objunlock(), objunref(), blist_obj::prev, bucket_list::version, and bucket_loop::version.