VSF Documented
Data Structures | Macros | Typedefs | Enumerations | Functions
argtable3_private.h File Reference
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  arg_hashtable_entry
 
struct  arg_hashtable
 
struct  arg_hashtable_itr
 

Macros

#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); }
 

Typedefs

typedef void() arg_panicfn(const char *fmt,...)
 
typedef struct arg_hashtable arg_hashtable_t
 

Enumerations

enum  {
  ARG_ERR_MINCOUNT = 1 ,
  ARG_ERR_MAXCOUNT ,
  ARG_ERR_BADINT ,
  ARG_ERR_OVERFLOW ,
  ARG_ERR_BADDOUBLE ,
  ARG_ERR_BADDATE ,
  ARG_ERR_REGNOMATCH
}
 

Functions

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_targ_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.
 

hashtable_change

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
hthe 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_targ_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.
 

Macro Definition Documentation

◆ ARG_ENABLE_TRACE

#define ARG_ENABLE_TRACE   0

◆ ARG_ENABLE_LOG

#define ARG_ENABLE_LOG   0

◆ ARG_TRACE

#define ARG_TRACE (   x)
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

#define ARG_LOG (   x)
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

#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); }

◆ ARG_DEFINE_HASHTABLE_SEARCH

#define ARG_DEFINE_HASHTABLE_SEARCH (   fnname,
  keytype,
  valuetype 
)     valuetype* fnname(arg_hashtable_t* h, keytype* k) { return (valuetype*)(arg_hashtable_search(h, k)); }

◆ ARG_DEFINE_HASHTABLE_REMOVE

#define ARG_DEFINE_HASHTABLE_REMOVE (   fnname,
  keytype,
  valuetype 
)     void fnname(arg_hashtable_t* h, keytype* k) { arg_hashtable_remove(h, k); }

◆ 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)); }

Typedef Documentation

◆ arg_panicfn

typedef void() arg_panicfn(const char *fmt,...)

◆ arg_hashtable_t

◆ arg_hashtable_itr_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ARG_ERR_MINCOUNT 
ARG_ERR_MAXCOUNT 
ARG_ERR_BADINT 
ARG_ERR_OVERFLOW 
ARG_ERR_BADDOUBLE 
ARG_ERR_BADDATE 
ARG_ERR_REGNOMATCH 

Function Documentation

◆ dbg_printf()

void dbg_printf ( const char *  fmt,
  ... 
)
extern

◆ arg_set_panic()

void arg_set_panic ( arg_panicfn proc)
extern

◆ xmalloc()

void * xmalloc ( size_t  size)
extern

◆ xcalloc()

void * xcalloc ( size_t  count,
size_t  size 
)
extern

◆ xrealloc()

void * xrealloc ( void *  ptr,
size_t  size 
)
extern

◆ xfree()

void xfree ( void *  ptr)
extern

◆ 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
minsizeminimum initial size of hash table
hashfnfunction for hashing keys
eqfnfunction for determining key equality
Returns
newly created hash table or NULL on failure

◆ arg_hashtable_insert()

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.

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
hthe hash table to insert into
kthe key - hash table claims ownership and will free on removal
vthe value - does not claim ownership
Returns
non-zero for successful insertion

◆ arg_hashtable_search()

void * arg_hashtable_search ( arg_hashtable_t h,
const void *  k 
)

Search the specified key in the hash table.

Parameters
hthe hash table to search
kthe key to search for - does not claim ownership
Returns
the value associated with the key, or NULL if none found

◆ arg_hashtable_remove()

void arg_hashtable_remove ( arg_hashtable_t h,
const void *  k 
)

Remove the specified key from the hash table.

Parameters
hthe hash table to remove the item from
kthe key to search for - does not claim ownership

◆ arg_hashtable_count()

unsigned int arg_hashtable_count ( arg_hashtable_t h)

Return the number of keys in the hash table.

Parameters
hthe hash table
Returns
the number of items stored in the hash table

◆ arg_hashtable_change()

int arg_hashtable_change ( arg_hashtable_t h,
void *  k,
void *  v 
)

◆ arg_hashtable_destroy()

void arg_hashtable_destroy ( arg_hashtable_t h,
int  free_values 
)

Free the hash table and the memory allocated for each key-value pair.

Parameters
hthe hash table
free_valueswhether to call 'free' on the remaining values

◆ arg_hashtable_itr_create()

arg_hashtable_itr_t * arg_hashtable_itr_create ( arg_hashtable_t h)

◆ arg_hashtable_itr_destroy()

void arg_hashtable_itr_destroy ( arg_hashtable_itr_t itr)

◆ arg_hashtable_itr_key()

void * arg_hashtable_itr_key ( arg_hashtable_itr_t i)
extern

Return the value of the (key,value) pair at the current position.

◆ arg_hashtable_itr_value()

void * arg_hashtable_itr_value ( arg_hashtable_itr_t i)
extern

Return the value of the (key,value) pair at the current position.

◆ arg_hashtable_itr_advance()

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.

◆ arg_hashtable_itr_remove()

int arg_hashtable_itr_remove ( arg_hashtable_itr_t itr)

Remove current element and advance the iterator to the next element.

◆ arg_hashtable_itr_search()

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.

Returns
Zero if not found.
Generated from commit: vsfteam/vsf@c3767bf