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

struct nl_object* nl_object_alloc ( struct nl_object_ops ops  )  [read]

Allocate a new object of kind specified by the operations handle

  • ops cache operations handle
    Returns:
    The new object or NULL

Definition at line 42 of file object.c.

References nl_object_ops::oo_constructor, and nl_object_ops::oo_size.

Referenced by nl_object_alloc_name(), and nl_object_clone().

{
      struct nl_object *new;

      if (ops->oo_size < sizeof(*new))
            BUG();

      new = calloc(1, ops->oo_size);
      if (!new)
            return NULL;

      new->ce_refcnt = 1;
      nl_init_list_head(&new->ce_list);

      new->ce_ops = ops;
      if (ops->oo_constructor)
            ops->oo_constructor(new);

      NL_DBG(4, "Allocated new object %p\n", new);

      return new;
}


Generated by  Doxygen 1.6.0   Back to index