]> granicus.if.org Git - libass/commitdiff
Make cache_*_add functions return the pointer to new (copied) value.
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 3 May 2007 19:13:54 +0000 (19:13 +0000)
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Thu, 3 May 2007 19:13:54 +0000 (19:13 +0000)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23229 b3059339-0415-0410-9bf9-f77b7e298cf2

libass/ass_cache.c
libass/ass_cache.h

index 1ea9b48435fb0b34ad9fef34db6f4fb8228755d1..5198700fdd5678f6f64fa9a03e29d31f644df98c 100644 (file)
@@ -130,7 +130,7 @@ void hashmap_done(hashmap_t* map)
 }
 
 // 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 @@ void hashmap_insert(hashmap_t* map, void* key, void* value)
        (*next)->next = 0;
 
        map->count ++;
+       return (*next)->value;
 }
 
 void* hashmap_find(hashmap_t* map, void* key)
@@ -207,9 +208,9 @@ ass_font_t* ass_font_cache_find(ass_font_desc_t* desc)
  * \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 @@ static void bitmap_hash_dtor(void* key, size_t key_size, void* value, size_t val
        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 @@ static void glyph_hash_dtor(void* key, size_t key_size, void* value, size_t valu
        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);
 }
 
 /**
index 89e69f783f2619966c4c2e0c8091ba75ec7b12c6..2983664a23e579e57a43f1c130a74fd2a0104ce5 100644 (file)
@@ -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 @@ typedef struct bitmap_hash_val_s {
 } 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 @@ typedef struct glyph_hash_val_s {
 } 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_t* hashmap_init(size_t key_size, size_t value_size, int nbuckets,
                        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