Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

struct nl_cache* nl_cache_subset ( struct nl_cache *  orig,
struct nl_object *  filter 
) [read]

Allocate a new cache containing a subset of a cache

  • orig Original cache to be based on
  • filter Filter defining the subset to be filled into new cache
    Returns:
    A newly allocated cache or NULL.

Definition at line 234 of file cache.c.

References nl_cache_add(), nl_cache_alloc(), and nl_object_match_filter().

{
      struct nl_cache *cache;
      struct nl_object_ops *ops;
      struct nl_object *obj;

      if (!filter)
            BUG();

      cache = nl_cache_alloc(orig->c_ops);
      if (!cache)
            return NULL;

      ops = orig->c_ops->co_obj_ops;

      nl_list_for_each_entry(obj, &orig->c_items, ce_list) {
            if (!nl_object_match_filter(obj, filter))
                  continue;

            nl_cache_add(cache, obj);
      }

      return cache;
}


Generated by  Doxygen 1.6.0   Back to index