Functions
linkhash.c File Reference
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stddef.h>
#include <limits.h>
#include "linkhash.h"
Include dependency graph for linkhash.c:

Go to the source code of this file.

Functions

void lh_abort (const char *msg,...)
int lh_char_equal (void *k1, void *k2)
unsigned long lh_char_hash (void *k)
struct lh_tablelh_kchar_table_new (int size, char *name, lh_entry_free_fn *free_fn)
struct lh_tablelh_kptr_table_new (int size, char *name, lh_entry_free_fn *free_fn)
int lh_ptr_equal (void *k1, void *k2)
unsigned long lh_ptr_hash (void *k)
int lh_table_delete (struct lh_table *t, void *k)
int lh_table_delete_entry (struct lh_table *t, struct lh_entry *e)
void lh_table_free (struct lh_table *t)
int lh_table_insert (struct lh_table *t, void *k, void *v)
void * lh_table_lookup (struct lh_table *t, void *k)
struct lh_entrylh_table_lookup_entry (struct lh_table *t, void *k)
struct lh_tablelh_table_new (int size, char *name, lh_entry_free_fn *free_fn, lh_hash_fn *hash_fn, lh_equal_fn *equal_fn)
void lh_table_resize (struct lh_table *t, int new_size)

Function Documentation

void lh_abort ( const char *  msg,
  ... 
)

Definition at line 23 of file linkhash.c.

int lh_char_equal ( void *  k1,
void *  k2 
)

Definition at line 52 of file linkhash.c.

unsigned long lh_char_hash ( void *  k)

Definition at line 42 of file linkhash.c.

struct lh_table* lh_kchar_table_new ( int  size,
char *  name,
lh_entry_free_fn free_fn 
) [read]

Convenience function to create a new linkhash table with char keys.

Parameters:
sizeinitial table size.
nametable name.
free_fncallback function used to free memory for entries.
Returns:
a pointer onto the linkhash table.

Definition at line 79 of file linkhash.c.

struct lh_table* lh_kptr_table_new ( int  size,
char *  name,
lh_entry_free_fn free_fn 
) [read]

Convenience function to create a new linkhash table with ptr keys.

Parameters:
sizeinitial table size.
nametable name.
free_fncallback function used to free memory for entries.
Returns:
a pointer onto the linkhash table.

Definition at line 85 of file linkhash.c.

int lh_ptr_equal ( void *  k1,
void *  k2 
)

Definition at line 37 of file linkhash.c.

unsigned long lh_ptr_hash ( void *  k)

Pre-defined hash and equality functions

Definition at line 31 of file linkhash.c.

int lh_table_delete ( struct lh_table t,
void *  k 
)

Delete a record from the table. If a callback free function is provided then it is called for the for the item being deleted.

Parameters:
tthe table to delete from.
ka pointer to the key to delete.
Returns:
0 if the item was deleted.
-1 if it was not found.

Definition at line 211 of file linkhash.c.

int lh_table_delete_entry ( struct lh_table t,
struct lh_entry e 
)

Delete a record from the table. If a callback free function is provided then it is called for the for the item being deleted.

Parameters:
tthe table to delete from.
ea pointer to the entry to delete.
Returns:
0 if the item was deleted.
-1 if it was not found.

Definition at line 182 of file linkhash.c.

void lh_table_free ( struct lh_table t)

Free a linkhash table. If a callback free function is provided then it is called for all entries in the table.

Parameters:
ttable to free.

Definition at line 111 of file linkhash.c.

int lh_table_insert ( struct lh_table t,
void *  k,
void *  v 
)

Insert a record into the table.

Parameters:
tthe table to insert into.
ka pointer to the key to insert.
va pointer to the value to insert.

Definition at line 124 of file linkhash.c.

void* lh_table_lookup ( struct lh_table t,
void *  k 
)

Lookup a record into the table

Parameters:
tthe table to lookup
ka pointer to the key to lookup
Returns:
a pointer to the found value or NULL if it does not exist.

Definition at line 174 of file linkhash.c.

struct lh_entry* lh_table_lookup_entry ( struct lh_table t,
void *  k 
) [read]

Lookup a record into the table.

Parameters:
tthe table to lookup
ka pointer to the key to lookup
Returns:
a pointer to the record structure of the value or NULL if it does not exist.

Definition at line 158 of file linkhash.c.

struct lh_table* lh_table_new ( int  size,
char *  name,
lh_entry_free_fn free_fn,
lh_hash_fn hash_fn,
lh_equal_fn equal_fn 
) [read]

Create a new linkhash table.

Parameters:
sizeinitial table size. The table is automatically resized although this incurs a performance penalty.
namethe table name.
free_fncallback function used to free memory for entries when lh_table_free or lh_table_delete is called. If NULL is provided, then memory for keys and values must be freed by the caller.
hash_fnfunction used to hash keys. 2 standard ones are defined: lh_ptr_hash and lh_char_hash for hashing pointer values and C strings respectively.
equal_fncomparison function to compare keys. 2 standard ones defined: lh_ptr_hash and lh_char_hash for comparing pointer values and C strings respectively.
Returns:
a pointer onto the linkhash table.

Definition at line 57 of file linkhash.c.

void lh_table_resize ( struct lh_table t,
int  new_size 
)

Definition at line 91 of file linkhash.c.



csm
Author(s): Andrea Censi
autogenerated on Fri May 17 2019 02:28:33