Mercurial > mplayer.hg
changeset 23211:d9b4bfea1093
Make cache_*_add functions return the pointer to new (copied) value.
author | eugeni |
---|---|
date | Thu, 03 May 2007 19:13:54 +0000 |
parents | 8e6bc75d21ce |
children | c932f521344d |
files | libass/ass_cache.c libass/ass_cache.h |
diffstat | 2 files changed, 12 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/libass/ass_cache.c Thu May 03 17:28:23 2007 +0000 +++ b/libass/ass_cache.c Thu May 03 19:13:54 2007 +0000 @@ -130,7 +130,7 @@ } // does nothing if key already exists -void hashmap_insert(hashmap_t* map, void* key, void* value) +void* hashmap_insert(hashmap_t* map, void* key, void* value) { unsigned hash = map->hash(key, map->key_size); hashmap_item_t** next = map->root + (hash % map->nbuckets); @@ -148,6 +148,7 @@ (*next)->next = 0; map->count ++; + return (*next)->value; } void* hashmap_find(hashmap_t* map, void* key) @@ -207,9 +208,9 @@ * \brief Add a face struct to cache. * \param font font struct */ -void ass_font_cache_add(ass_font_t* font) +void* ass_font_cache_add(ass_font_t* font) { - hashmap_insert(font_cache, &(font->desc), font); + return hashmap_insert(font_cache, &(font->desc), font); } void ass_font_cache_init(void) @@ -240,9 +241,9 @@ free(value); } -void cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val) +void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val) { - hashmap_insert(bitmap_cache, key, val); + return hashmap_insert(bitmap_cache, key, val); } /** @@ -288,9 +289,9 @@ free(value); } -void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val) +void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val) { - hashmap_insert(glyph_cache, key, val); + return hashmap_insert(glyph_cache, key, val); } /**
--- a/libass/ass_cache.h Thu May 03 17:28:23 2007 +0000 +++ b/libass/ass_cache.h Thu May 03 19:13:54 2007 +0000 @@ -23,7 +23,7 @@ void ass_font_cache_init(void); ass_font_t* ass_font_cache_find(ass_font_desc_t* desc); -void ass_font_cache_add(ass_font_t* font); +void* ass_font_cache_add(ass_font_t* font); void ass_font_cache_done(void); @@ -53,7 +53,7 @@ } bitmap_hash_val_t; void ass_bitmap_cache_init(void); -void cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val); +void* cache_add_bitmap(bitmap_hash_key_t* key, bitmap_hash_val_t* val); bitmap_hash_val_t* cache_find_bitmap(bitmap_hash_key_t* key); void ass_bitmap_cache_reset(void); void ass_bitmap_cache_done(void); @@ -77,7 +77,7 @@ } glyph_hash_val_t; void ass_glyph_cache_init(void); -void cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val); +void* cache_add_glyph(glyph_hash_key_t* key, glyph_hash_val_t* val); glyph_hash_val_t* cache_find_glyph(glyph_hash_key_t* key); void ass_glyph_cache_reset(void); void ass_glyph_cache_done(void); @@ -91,7 +91,7 @@ hashmap_item_dtor_t item_dtor, hashmap_key_compare_t key_compare, hashmap_hash_t hash); void hashmap_done(hashmap_t* map); -void hashmap_insert(hashmap_t* map, void* key, void* value); +void* hashmap_insert(hashmap_t* map, void* key, void* value); void* hashmap_find(hashmap_t* map, void* key); #endif