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
diff --git a/linkhash.h b/linkhash.h
index 785ddf4..9b5ef9d 100644
--- a/linkhash.h
+++ b/linkhash.h
@@ -36,11 +36,11 @@
/**
* 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 @@
/**
* The value.
*/
- void *v;
+ const void *v;
/**
* The next entry
*/
@@ -106,7 +106,7 @@
/**
* Name of the hash table.
*/
- char *name;
+ const char *name;
/**
* The first entry.
@@ -132,11 +132,11 @@
/**
* 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 @@
* 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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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 @@
* @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, ...);