forked from enlightenment/efl
Add const modifier for compare and hash functions.
SVN revision: 25515
This commit is contained in:
parent
3c480bdc56
commit
3aa4e62438
|
@ -46,10 +46,10 @@ extern "C" {
|
||||||
typedef void (*Ecore_Free_Cb) (void *data);
|
typedef void (*Ecore_Free_Cb) (void *data);
|
||||||
# define ECORE_FREE_CB(func) ((Ecore_Free_Cb)func)
|
# define ECORE_FREE_CB(func) ((Ecore_Free_Cb)func)
|
||||||
|
|
||||||
typedef unsigned int (*Ecore_Hash_Cb) (void *key);
|
typedef unsigned int (*Ecore_Hash_Cb) (const void *key);
|
||||||
# define ECORE_HASH_CB(function) ((Ecore_Hash_Cb)function)
|
# define ECORE_HASH_CB(function) ((Ecore_Hash_Cb)function)
|
||||||
|
|
||||||
typedef int (*Ecore_Compare_Cb) (void *data1, void *data2);
|
typedef int (*Ecore_Compare_Cb) (const void *data1, const void *data2);
|
||||||
# define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
|
# define ECORE_COMPARE_CB(function) ((Ecore_Compare_Cb)function)
|
||||||
|
|
||||||
typedef struct _ecore_list Ecore_List;
|
typedef struct _ecore_list Ecore_List;
|
||||||
|
@ -75,11 +75,11 @@ extern "C" {
|
||||||
list of current node */
|
list of current node */
|
||||||
};
|
};
|
||||||
|
|
||||||
EAPI int ecore_direct_compare(void *key1, void *key2);
|
EAPI int ecore_direct_compare(const void *key1, const void *key2);
|
||||||
EAPI int ecore_str_compare(void *key1, void *key2);
|
EAPI int ecore_str_compare(const void *key1, const void *key2);
|
||||||
|
|
||||||
EAPI unsigned int ecore_direct_hash(void *key);
|
EAPI unsigned int ecore_direct_hash(const void *key);
|
||||||
EAPI unsigned int ecore_str_hash(void *key);
|
EAPI unsigned int ecore_str_hash(const void *key);
|
||||||
|
|
||||||
/* Creating and initializing new list structures */
|
/* Creating and initializing new list structures */
|
||||||
EAPI Ecore_List *ecore_list_new(void);
|
EAPI Ecore_List *ecore_list_new(void);
|
||||||
|
@ -241,7 +241,7 @@ extern "C" {
|
||||||
EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
|
EAPI Ecore_List *ecore_hash_keys(Ecore_Hash *hash);
|
||||||
|
|
||||||
/* Retrieve and store data into the hash */
|
/* Retrieve and store data into the hash */
|
||||||
EAPI void *ecore_hash_get(Ecore_Hash *hash, void *key);
|
EAPI void *ecore_hash_get(Ecore_Hash *hash, const void *key);
|
||||||
EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
|
EAPI int ecore_hash_set(Ecore_Hash *hash, void *key, void *value);
|
||||||
EAPI void *ecore_hash_remove(Ecore_Hash *hash, void *key);
|
EAPI void *ecore_hash_remove(Ecore_Hash *hash, void *key);
|
||||||
EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
|
EAPI void ecore_hash_dump_graph(Ecore_Hash *hash);
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
|
|
||||||
/* Private hash manipulation functions */
|
/* Private hash manipulation functions */
|
||||||
static int _ecore_hash_add_node(Ecore_Hash *hash, Ecore_Hash_Node *node);
|
static int _ecore_hash_add_node(Ecore_Hash *hash, Ecore_Hash_Node *node);
|
||||||
static Ecore_Hash_Node * _ecore_hash_get_node(Ecore_Hash *hash, void *key);
|
static Ecore_Hash_Node * _ecore_hash_get_node(Ecore_Hash *hash, const void *key);
|
||||||
static int _ecore_hash_increase(Ecore_Hash *hash);
|
static int _ecore_hash_increase(Ecore_Hash *hash);
|
||||||
static int _ecore_hash_decrease(Ecore_Hash *hash);
|
static int _ecore_hash_decrease(Ecore_Hash *hash);
|
||||||
inline int _ecore_hash_rehash(Ecore_Hash *hash, Ecore_Hash_Node **old_table, int old_size);
|
inline int _ecore_hash_rehash(Ecore_Hash *hash, Ecore_Hash_Node **old_table, int old_size);
|
||||||
static int _ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd,
|
static int _ecore_hash_bucket_destroy(Ecore_Hash_Node *list, Ecore_Free_Cb keyd,
|
||||||
Ecore_Free_Cb valued);
|
Ecore_Free_Cb valued);
|
||||||
inline Ecore_Hash_Node * _ecore_hash_get_bucket(Ecore_Hash *hash,
|
inline Ecore_Hash_Node * _ecore_hash_get_bucket(Ecore_Hash *hash,
|
||||||
Ecore_Hash_Node *bucket, void *key);
|
Ecore_Hash_Node *bucket, const void *key);
|
||||||
|
|
||||||
static Ecore_Hash_Node *_ecore_hash_node_new(void *key, void *value);
|
static Ecore_Hash_Node *_ecore_hash_node_new(void *key, void *value);
|
||||||
static int _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value);
|
static int _ecore_hash_node_init(Ecore_Hash_Node *node, void *key, void *value);
|
||||||
|
@ -360,7 +360,7 @@ _ecore_hash_add_node(Ecore_Hash *hash, Ecore_Hash_Node *node)
|
||||||
* @ingroup Ecore_Data_Hash_ADT_Data_Group
|
* @ingroup Ecore_Data_Hash_ADT_Data_Group
|
||||||
*/
|
*/
|
||||||
EAPI void *
|
EAPI void *
|
||||||
ecore_hash_get(Ecore_Hash *hash, void *key)
|
ecore_hash_get(Ecore_Hash *hash, const void *key)
|
||||||
{
|
{
|
||||||
void *data;
|
void *data;
|
||||||
Ecore_Hash_Node *node;
|
Ecore_Hash_Node *node;
|
||||||
|
@ -459,7 +459,7 @@ ecore_hash_remove(Ecore_Hash *hash, void *key)
|
||||||
* @return Returns NULL on error, node corresponding to key on success
|
* @return Returns NULL on error, node corresponding to key on success
|
||||||
*/
|
*/
|
||||||
static Ecore_Hash_Node *
|
static Ecore_Hash_Node *
|
||||||
_ecore_hash_get_node(Ecore_Hash *hash, void *key)
|
_ecore_hash_get_node(Ecore_Hash *hash, const void *key)
|
||||||
{
|
{
|
||||||
unsigned int hash_val;
|
unsigned int hash_val;
|
||||||
Ecore_Hash_Node *node = NULL;
|
Ecore_Hash_Node *node = NULL;
|
||||||
|
@ -503,7 +503,7 @@ _ecore_hash_get_node(Ecore_Hash *hash, void *key)
|
||||||
* @return Returns NULL on error or not found, the found node on success
|
* @return Returns NULL on error or not found, the found node on success
|
||||||
*/
|
*/
|
||||||
inline Ecore_Hash_Node *
|
inline Ecore_Hash_Node *
|
||||||
_ecore_hash_get_bucket(Ecore_Hash *hash, Ecore_Hash_Node *bucket, void *key)
|
_ecore_hash_get_bucket(Ecore_Hash *hash, Ecore_Hash_Node *bucket, const void *key)
|
||||||
{
|
{
|
||||||
Ecore_Hash_Node *prev = NULL;
|
Ecore_Hash_Node *prev = NULL;
|
||||||
Ecore_Hash_Node *node = NULL;
|
Ecore_Hash_Node *node = NULL;
|
||||||
|
|
|
@ -53,7 +53,7 @@ ecore_print_warning(const char *function, const char *sparam)
|
||||||
* @return The key cast to an unsigned int.
|
* @return The key cast to an unsigned int.
|
||||||
*/
|
*/
|
||||||
EAPI unsigned int
|
EAPI unsigned int
|
||||||
ecore_direct_hash(void *key)
|
ecore_direct_hash(const void *key)
|
||||||
{
|
{
|
||||||
return ((unsigned int) key);
|
return ((unsigned int) key);
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,11 @@ ecore_direct_hash(void *key)
|
||||||
* @return A computed hash value for @a key.
|
* @return A computed hash value for @a key.
|
||||||
*/
|
*/
|
||||||
EAPI unsigned int
|
EAPI unsigned int
|
||||||
ecore_str_hash(void *key)
|
ecore_str_hash(const void *key)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
char *k = (char *) key;
|
const char *k = key;
|
||||||
|
|
||||||
if (!k)
|
if (!k)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -89,7 +89,7 @@ ecore_str_hash(void *key)
|
||||||
* @return A strcmp style value to indicate the larger key
|
* @return A strcmp style value to indicate the larger key
|
||||||
*/
|
*/
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_direct_compare(void *key1, void *key2)
|
ecore_direct_compare(const void *key1, const void *key2)
|
||||||
{
|
{
|
||||||
unsigned int k1, k2;
|
unsigned int k1, k2;
|
||||||
|
|
||||||
|
@ -112,17 +112,17 @@ ecore_direct_compare(void *key1, void *key2)
|
||||||
* @return A strcmp style value to indicate the larger key
|
* @return A strcmp style value to indicate the larger key
|
||||||
*/
|
*/
|
||||||
EAPI int
|
EAPI int
|
||||||
ecore_str_compare(void *key1, void *key2)
|
ecore_str_compare(const void *key1, const void *key2)
|
||||||
{
|
{
|
||||||
char *k1, *k2;
|
const char *k1, *k2;
|
||||||
|
|
||||||
if (!key1 || !key2)
|
if (!key1 || !key2)
|
||||||
return ecore_direct_compare(key1, key2);
|
return ecore_direct_compare(key1, key2);
|
||||||
else if (key1 == key2)
|
else if (key1 == key2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
k1 = (char *) key1;
|
k1 = key1;
|
||||||
k2 = (char *) key2;
|
k2 = key2;
|
||||||
|
|
||||||
return strcmp(k1, k2);
|
return strcmp(k1, k2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue