mirror of
https://github.com/json-c/json-c.git
synced 2026-03-13 18:19:06 +08:00
Add const correctness to public interfaces
Gerard Krol, g dot c dot krol at student dot tudelft dot nl Update version number to 0.9 git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@27 327403b1-1117-474d-bef2-5cb71233fd97
This commit is contained in:
30
linkhash.h
30
linkhash.h
@@ -36,11 +36,11 @@ typedef void (lh_entry_free_fn) (struct lh_entry *e);
|
||||
/**
|
||||
* callback function prototypes
|
||||
*/
|
||||
typedef unsigned long (lh_hash_fn) (void *k);
|
||||
typedef unsigned long (lh_hash_fn) (const void *k);
|
||||
/**
|
||||
* callback function prototypes
|
||||
*/
|
||||
typedef int (lh_equal_fn) (void *k1, void *k2);
|
||||
typedef int (lh_equal_fn) (const void *k1, const void *k2);
|
||||
|
||||
/**
|
||||
* An entry in the hash table
|
||||
@@ -53,7 +53,7 @@ struct lh_entry {
|
||||
/**
|
||||
* The value.
|
||||
*/
|
||||
void *v;
|
||||
const void *v;
|
||||
/**
|
||||
* The next entry
|
||||
*/
|
||||
@@ -106,7 +106,7 @@ struct lh_table {
|
||||
/**
|
||||
* Name of the hash table.
|
||||
*/
|
||||
char *name;
|
||||
const char *name;
|
||||
|
||||
/**
|
||||
* The first entry.
|
||||
@@ -132,11 +132,11 @@ struct lh_table {
|
||||
/**
|
||||
* Pre-defined hash and equality functions
|
||||
*/
|
||||
extern unsigned long lh_ptr_hash(void *k);
|
||||
extern int lh_ptr_equal(void *k1, void *k2);
|
||||
extern unsigned long lh_ptr_hash(const void *k);
|
||||
extern int lh_ptr_equal(const void *k1, const void *k2);
|
||||
|
||||
extern unsigned long lh_char_hash(void *k);
|
||||
extern int lh_char_equal(void *k1, void *k2);
|
||||
extern unsigned long lh_char_hash(const void *k);
|
||||
extern int lh_char_equal(const void *k1, const void *k2);
|
||||
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ for(entry = table->head; entry && ((tmp = entry->next) || 1); entry = tmp)
|
||||
* and C strings respectively.
|
||||
* @return a pointer onto the linkhash table.
|
||||
*/
|
||||
extern struct lh_table* lh_table_new(int size, char *name,
|
||||
extern struct lh_table* lh_table_new(int size, const char *name,
|
||||
lh_entry_free_fn *free_fn,
|
||||
lh_hash_fn *hash_fn,
|
||||
lh_equal_fn *equal_fn);
|
||||
@@ -183,7 +183,7 @@ extern struct lh_table* lh_table_new(int size, char *name,
|
||||
* @param free_fn callback function used to free memory for entries.
|
||||
* @return a pointer onto the linkhash table.
|
||||
*/
|
||||
extern struct lh_table* lh_kchar_table_new(int size, char *name,
|
||||
extern struct lh_table* lh_kchar_table_new(int size, const char *name,
|
||||
lh_entry_free_fn *free_fn);
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ extern struct lh_table* lh_kchar_table_new(int size, char *name,
|
||||
* @param free_fn callback function used to free memory for entries.
|
||||
* @return a pointer onto the linkhash table.
|
||||
*/
|
||||
extern struct lh_table* lh_kptr_table_new(int size, char *name,
|
||||
extern struct lh_table* lh_kptr_table_new(int size, const char *name,
|
||||
lh_entry_free_fn *free_fn);
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ extern void lh_table_free(struct lh_table *t);
|
||||
* @param k a pointer to the key to insert.
|
||||
* @param v a pointer to the value to insert.
|
||||
*/
|
||||
extern int lh_table_insert(struct lh_table *t, void *k, void *v);
|
||||
extern int lh_table_insert(struct lh_table *t, void *k, const void *v);
|
||||
|
||||
|
||||
/**
|
||||
@@ -223,7 +223,7 @@ extern int lh_table_insert(struct lh_table *t, void *k, void *v);
|
||||
* @param k a pointer to the key to lookup
|
||||
* @return a pointer to the record structure of the value or NULL if it does not exist.
|
||||
*/
|
||||
extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k);
|
||||
extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, const void *k);
|
||||
|
||||
/**
|
||||
* Lookup a record into the table
|
||||
@@ -231,7 +231,7 @@ extern struct lh_entry* lh_table_lookup_entry(struct lh_table *t, void *k);
|
||||
* @param k a pointer to the key to lookup
|
||||
* @return a pointer to the found value or NULL if it does not exist.
|
||||
*/
|
||||
extern void* lh_table_lookup(struct lh_table *t, void *k);
|
||||
extern const void* lh_table_lookup(struct lh_table *t, const void *k);
|
||||
|
||||
|
||||
/**
|
||||
@@ -255,7 +255,7 @@ extern int lh_table_delete_entry(struct lh_table *t, struct lh_entry *e);
|
||||
* @return 0 if the item was deleted.
|
||||
* @return -1 if it was not found.
|
||||
*/
|
||||
extern int lh_table_delete(struct lh_table *t, void *k);
|
||||
extern int lh_table_delete(struct lh_table *t, const void *k);
|
||||
|
||||
|
||||
void lh_abort(const char *msg, ...);
|
||||
|
||||
Reference in New Issue
Block a user