}
// 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);
(*next)->next = 0;
map->count ++;
+ return (*next)->value;
}
void* hashmap_find(hashmap_t* map, void* key)
* \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)
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);
}
/**
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);
}
/**
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);
} 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);
} 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);
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