void vg_context_remove_object(struct vg_context *ctx,
                              struct vg_object *obj)
{
   if (ctx) {
      struct cso_hash *hash = ctx->owned_objects[obj->type];
      if (!hash)
         return;
      cso_hash_take(hash, (unsigned) obj->handle);
   }
}
Ejemplo n.º 2
0
void vg_context_remove_object(struct vg_context *ctx,
                              enum vg_object_type type,
                              void *ptr)
{
   if (ctx) {
      struct cso_hash *hash = ctx->owned_objects[type];
      if (!hash)
         return;
      cso_hash_take(hash, (unsigned)(long)ptr);
   }
}
Ejemplo n.º 3
0
static VGboolean del_glyph(struct vg_font *font,
                           VGuint glyphIndex)
{
   struct vg_glyph *glyph;

   glyph = (struct vg_glyph *)
      cso_hash_take(font->glyphs, (unsigned) glyphIndex);
   FREE(glyph);

   return (glyph != NULL);
}
Ejemplo n.º 4
0
static INLINE void sanitize_cb(struct cso_hash *hash, enum cso_cache_type type,
                               int max_size, void *user_data)
{
   /* if we're approach the maximum size, remove fourth of the entries
    * otherwise every subsequent call will go through the same */
   int hash_size = cso_hash_size(hash);
   int max_entries = (max_size > hash_size) ? max_size : hash_size;
   int to_remove =  (max_size < max_entries) * max_entries/4;
   if (hash_size > max_size)
      to_remove += hash_size - max_size;
   while (to_remove) {
      /*remove elements until we're good */
      /*fixme: currently we pick the nodes to remove at random*/
      struct cso_hash_iter iter = cso_hash_first_node(hash);
      void  *cso = cso_hash_take(hash, cso_hash_iter_key(iter));
      delete_cso(cso, type);
      --to_remove;
   }
}
Ejemplo n.º 5
0
/**
 * Remove all entries from the map, calling the delete callback for each.
 * \param user  passed to the delete callback as the last param.
 */
void
util_keymap_remove_all(struct keymap *map, void *user)
{
   struct cso_hash_iter iter;
   struct keymap_item *item;

   assert(map);
   if (!map)
      return;

   iter = cso_hash_first_node(map->cso);
   while (!cso_hash_iter_is_null(iter)) {
      item = (struct keymap_item *)
         cso_hash_take(map->cso, cso_hash_iter_key(iter));
      map->delete_func(map, item->key, item->value, user);
      FREE(item->key);
      FREE(item);
      iter = cso_hash_first_node(map->cso);
   }
}
Ejemplo n.º 6
0
void * cso_take_state(struct cso_cache *sc,
                      unsigned hash_key, enum cso_cache_type type)
{
   struct cso_hash *hash = _cso_hash_for_type(sc, type);
   return cso_hash_take(hash, hash_key);
}