Add const: evas_hash.c

As agreed on IRC, evas_hash_foreach() now takes const, to make clear
that hash shouldn't be changed. If one wants to change he must do a
cast and return 0.  However this will require users to be updated in
applications.


SVN revision: 33708
This commit is contained in:
Gustavo Sverzut Barbieri 2008-02-08 19:55:03 +00:00
parent 72b005350a
commit 7cb7216314
5 changed files with 19 additions and 15 deletions

View File

@ -387,11 +387,11 @@ extern "C" {
EAPI Evas_Hash *evas_hash_add (Evas_Hash *hash, const char *key, const void *data);
EAPI Evas_Hash *evas_hash_direct_add (Evas_Hash *hash, const char *key, const void *data);
EAPI Evas_Hash *evas_hash_del (Evas_Hash *hash, const char *key, const void *data);
EAPI void *evas_hash_find (Evas_Hash *hash, const char *key);
EAPI void *evas_hash_find (const Evas_Hash *hash, const char *key);
EAPI void *evas_hash_modify (Evas_Hash *hash, const char *key, const void *data);
EAPI int evas_hash_size (Evas_Hash *hash);
EAPI int evas_hash_size (const Evas_Hash *hash);
EAPI void evas_hash_free (Evas_Hash *hash);
EAPI void evas_hash_foreach (Evas_Hash *hash, Evas_Bool (*func) (Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata);
EAPI void evas_hash_foreach (const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata);
EAPI int evas_hash_alloc_error (void);
EAPI const char *evas_stringshare_add (const char *str);

View File

@ -55,7 +55,7 @@ evas_cache_image_init(const Evas_Cache_Image_Func *cb)
}
static Evas_Bool
_evas_cache_image_free_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
_evas_cache_image_free_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
Evas_Cache_Image *cache = fdata;
RGBA_Image *im = data;

View File

@ -24,7 +24,7 @@ struct _Fndat
};
/* private methods for font dir cache */
static Evas_Bool font_cache_dir_free(Evas_Hash *hash, const char *key, void *data, void *fdata);
static Evas_Bool font_cache_dir_free(const Evas_Hash *hash, const char *key, void *data, void *fdata);
static Evas_Font_Dir *object_text_font_cache_dir_update(char *dir, Evas_Font_Dir *fd);
static Evas_Font *object_text_font_cache_font_find_x(Evas_Font_Dir *fd, char *font);
static Evas_Font *object_text_font_cache_font_find_file(Evas_Font_Dir *fd, char *font);
@ -439,7 +439,7 @@ evas_font_dir_available_list_free(Evas_List *available)
/* private stuff */
static Evas_Bool
font_cache_dir_free(Evas_Hash *hash, const char *key, void *data, void *fdata)
font_cache_dir_free(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
object_text_font_cache_dir_del((char *) key, data);
return 1;

View File

@ -266,7 +266,7 @@ evas_hash_del(Evas_Hash *hash, const char *key, const void *data)
* @ingroup Evas_Hash_Data
*/
EAPI void *
evas_hash_find(Evas_Hash *hash, const char *key)
evas_hash_find(const Evas_Hash *hash, const char *key)
{
int hash_num;
Evas_Hash_El *el;
@ -282,8 +282,12 @@ evas_hash_find(Evas_Hash *hash, const char *key)
{
if (l != hash->buckets[hash_num])
{
hash->buckets[hash_num] = evas_object_list_remove(hash->buckets[hash_num], el);
hash->buckets[hash_num] = evas_object_list_prepend(hash->buckets[hash_num], el);
Evas_Object_List *bucket;
bucket = hash->buckets[hash_num];
bucket = evas_object_list_remove(bucket, el);
bucket = evas_object_list_prepend(bucket, el);
((Evas_Hash *)hash)->buckets[hash_num] = bucket;
}
return el->data;
}
@ -344,7 +348,7 @@ evas_hash_modify(Evas_Hash *hash, const char *key, const void *data)
* @ingroup Evas_Hash_General_Group
*/
EAPI int
evas_hash_size(Evas_Hash *hash)
evas_hash_size(const Evas_Hash *hash)
{
if (!hash) return 0;
return 256;
@ -429,7 +433,7 @@ evas_hash_free(Evas_Hash *hash)
* @ingroup Evas_Hash_General_Group
*/
EAPI void
evas_hash_foreach(Evas_Hash *hash, Evas_Bool (*func) (Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata)
evas_hash_foreach(const Evas_Hash *hash, Evas_Bool (*func) (const Evas_Hash *hash, const char *key, void *data, void *fdata), const void *fdata)
{
int i, size;

View File

@ -11,8 +11,8 @@ static int font_cache = 0;
static Evas_Object_List * fonts_src = NULL;
static Evas_Object_List * fonts = NULL;
static Evas_Bool font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
static Evas_Bool font_flush_free_glyph_cb(Evas_Hash *hash, const char *key, void *data, void *fdata);
static Evas_Bool font_modify_cache_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata);
static Evas_Bool font_flush_free_glyph_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata);
EAPI RGBA_Font_Source *
evas_common_font_source_memory_load(const char *name, const void *data, int data_size)
@ -476,7 +476,7 @@ evas_common_font_memory_hinting_add(RGBA_Font *fn, const char *name, int size, c
}
static Evas_Bool
font_modify_cache_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
font_modify_cache_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
int *dir;
RGBA_Font_Glyph *fg;
@ -527,7 +527,7 @@ evas_common_font_flush(void)
}
static Evas_Bool
font_flush_free_glyph_cb(Evas_Hash *hash, const char *key, void *data, void *fdata)
font_flush_free_glyph_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata)
{
RGBA_Font_Glyph *fg;