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

int nl_cache_add ( struct nl_cache *  cache,
struct nl_object *  obj 

Add an element to the cache.

  • cache cache to add a element to
  • obj Common obj to be added to the cache
Adds the object obj to the tail of the cache cache and. The cache is enlarged as needed.

0 or a negative error code.

Definition at line 269 of file cache.c.

References nl_object_clone(), nl_object_put(), and nl_object_shared().

      struct nl_object *new;

      if (nl_object_shared(obj)) {
            new = nl_object_clone(obj);
            if (!new)
                  return nl_errno(ENOMEM);

      } else
            new = obj;

      new->ce_cache = cache;

      nl_list_add_tail(&new->ce_list, &cache->c_items);

      NL_DBG(1, "Added %p to cache %p.\n", new, cache);

      return 0;

Generated by  Doxygen 1.6.0   Back to index