#include <stdlib.h>
Go to the source code of this file.
|
| #define | ARG_ENABLE_TRACE 0 |
| |
| #define | ARG_ENABLE_LOG 0 |
| |
| #define | ARG_TRACE(x) |
| |
| #define | ARG_LOG(x) |
| |
| #define | xmalloc argtable3_xmalloc |
| |
| #define | xcalloc argtable3_xcalloc |
| |
| #define | xrealloc argtable3_xrealloc |
| |
| #define | xfree argtable3_xfree |
| |
| #define | ARG_DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) int fnname(arg_hashtable_t* h, keytype* k, valuetype* v) { return arg_hashtable_insert(h, k, v); } |
| |
| #define | ARG_DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) valuetype* fnname(arg_hashtable_t* h, keytype* k) { return (valuetype*)(arg_hashtable_search(h, k)); } |
| |
| #define | ARG_DEFINE_HASHTABLE_REMOVE(fnname, keytype, valuetype) void fnname(arg_hashtable_t* h, keytype* k) { arg_hashtable_remove(h, k); } |
| |
|
| void | dbg_printf (const char *fmt,...) |
| |
| void | arg_set_panic (arg_panicfn *proc) |
| |
| void * | xmalloc (size_t size) |
| |
| void * | xcalloc (size_t count, size_t size) |
| |
| void * | xrealloc (void *ptr, size_t size) |
| |
| void | xfree (void *ptr) |
| |
| arg_hashtable_t * | arg_hashtable_create (unsigned int minsize, unsigned int(*hashfn)(const void *), int(*eqfn)(const void *, const void *)) |
| | Create a hash table.
|
| |
| void | arg_hashtable_insert (arg_hashtable_t *h, void *k, void *v) |
| | This function will cause the table to expand if the insertion would take the ratio of entries to table size over the maximum load factor.
|
| |
| void * | arg_hashtable_search (arg_hashtable_t *h, const void *k) |
| | Search the specified key in the hash table.
|
| |
| void | arg_hashtable_remove (arg_hashtable_t *h, const void *k) |
| | Remove the specified key from the hash table.
|
| |
| unsigned int | arg_hashtable_count (arg_hashtable_t *h) |
| | Return the number of keys in the hash table.
|
| |
|
Change the value associated with the key.
function to change the value associated with a key, where there already exists a value bound to the key in the hash table. Source due to Holger Schemel.
- Parameters
-
| h | the hash table |
| key | |
| value | |
|
| #define | ARG_DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype) int fnname(arg_hashtable_itr_t* i, arg_hashtable_t* h, keytype* k) { return (arg_hashtable_iterator_search(i, h, k)); } |
| |
| typedef struct arg_hashtable_itr | arg_hashtable_itr_t |
| |
| int | arg_hashtable_change (arg_hashtable_t *h, void *k, void *v) |
| |
| void | arg_hashtable_destroy (arg_hashtable_t *h, int free_values) |
| | Free the hash table and the memory allocated for each key-value pair.
|
| |
| arg_hashtable_itr_t * | arg_hashtable_itr_create (arg_hashtable_t *h) |
| |
| void | arg_hashtable_itr_destroy (arg_hashtable_itr_t *itr) |
| |
| void * | arg_hashtable_itr_key (arg_hashtable_itr_t *i) |
| | Return the value of the (key,value) pair at the current position.
|
| |
| void * | arg_hashtable_itr_value (arg_hashtable_itr_t *i) |
| | Return the value of the (key,value) pair at the current position.
|
| |
| int | arg_hashtable_itr_advance (arg_hashtable_itr_t *itr) |
| | Advance the iterator to the next element. Returns zero if advanced to end of table.
|
| |
| int | arg_hashtable_itr_remove (arg_hashtable_itr_t *itr) |
| | Remove current element and advance the iterator to the next element.
|
| |
| int | arg_hashtable_itr_search (arg_hashtable_itr_t *itr, arg_hashtable_t *h, void *k) |
| | Search and overwrite the supplied iterator, to point to the entry matching the supplied key.
|
| |
◆ ARG_ENABLE_TRACE
| #define ARG_ENABLE_TRACE 0 |
◆ ARG_ENABLE_LOG
◆ ARG_TRACE
Value: do { \
} while (0)
#define ARG_ENABLE_TRACE
Definition argtable3_private.h:43
void dbg_printf(const char *fmt,...)
Definition arg_utils.c:52
◆ ARG_LOG
Value: do { \
} while (0)
#define ARG_ENABLE_LOG
Definition argtable3_private.h:44
◆ xmalloc
| #define xmalloc argtable3_xmalloc |
◆ xcalloc
| #define xcalloc argtable3_xcalloc |
◆ xrealloc
| #define xrealloc argtable3_xrealloc |
◆ xfree
| #define xfree argtable3_xfree |
◆ ARG_DEFINE_HASHTABLE_INSERT
◆ ARG_DEFINE_HASHTABLE_SEARCH
◆ ARG_DEFINE_HASHTABLE_REMOVE
◆ ARG_DEFINE_HASHTABLE_ITERATOR_SEARCH
| #define ARG_DEFINE_HASHTABLE_ITERATOR_SEARCH |
( |
|
fnname, |
|
|
|
keytype |
|
) |
| int fnname(arg_hashtable_itr_t* i, arg_hashtable_t* h, keytype* k) { return (arg_hashtable_iterator_search(i, h, k)); } |
◆ arg_panicfn
| typedef void() arg_panicfn(const char *fmt,...) |
◆ arg_hashtable_t
◆ arg_hashtable_itr_t
◆ anonymous enum
| Enumerator |
|---|
| ARG_ERR_MINCOUNT | |
| ARG_ERR_MAXCOUNT | |
| ARG_ERR_BADINT | |
| ARG_ERR_OVERFLOW | |
| ARG_ERR_BADDOUBLE | |
| ARG_ERR_BADDATE | |
| ARG_ERR_REGNOMATCH | |
◆ dbg_printf()
| void dbg_printf |
( |
const char * |
fmt, |
|
|
|
... |
|
) |
| |
|
extern |
◆ arg_set_panic()
◆ xmalloc()
◆ xcalloc()
◆ xrealloc()
| void * xrealloc |
( |
void * |
ptr, |
|
|
size_t |
size |
|
) |
| |
|
extern |
◆ xfree()
◆ arg_hashtable_create()
| arg_hashtable_t * arg_hashtable_create |
( |
unsigned int |
minsize, |
|
|
unsigned int(*)(const void *) |
hashfn, |
|
|
int(*)(const void *, const void *) |
eqfn |
|
) |
| |
Create a hash table.
- Parameters
-
| minsize | minimum initial size of hash table |
| hashfn | function for hashing keys |
| eqfn | function for determining key equality |
- Returns
- newly created hash table or NULL on failure
◆ arg_hashtable_insert()
This function will cause the table to expand if the insertion would take the ratio of entries to table size over the maximum load factor.
This function does not check for repeated insertions with a duplicate key. The value returned when using a duplicate key is undefined – when the hash table changes size, the order of retrieval of duplicate key entries is reversed. If in doubt, remove before insert.
- Parameters
-
| h | the hash table to insert into |
| k | the key - hash table claims ownership and will free on removal |
| v | the value - does not claim ownership |
- Returns
- non-zero for successful insertion
◆ arg_hashtable_search()
Search the specified key in the hash table.
- Parameters
-
| h | the hash table to search |
| k | the key to search for - does not claim ownership |
- Returns
- the value associated with the key, or NULL if none found
◆ arg_hashtable_remove()
Remove the specified key from the hash table.
- Parameters
-
| h | the hash table to remove the item from |
| k | the key to search for - does not claim ownership |
◆ arg_hashtable_count()
Return the number of keys in the hash table.
- Parameters
-
- Returns
- the number of items stored in the hash table
◆ arg_hashtable_change()
◆ arg_hashtable_destroy()
Free the hash table and the memory allocated for each key-value pair.
- Parameters
-
| h | the hash table |
| free_values | whether to call 'free' on the remaining values |
◆ arg_hashtable_itr_create()
◆ arg_hashtable_itr_destroy()
◆ arg_hashtable_itr_key()
Return the value of the (key,value) pair at the current position.
◆ arg_hashtable_itr_value()
Return the value of the (key,value) pair at the current position.
◆ arg_hashtable_itr_advance()
Advance the iterator to the next element. Returns zero if advanced to end of table.
◆ arg_hashtable_itr_remove()
Remove current element and advance the iterator to the next element.
◆ arg_hashtable_itr_search()
Search and overwrite the supplied iterator, to point to the entry matching the supplied key.
- Returns
- Zero if not found.