-
- /* Last one (may be children->group itself). */
- group = next_group(&children->group);
-
- /* Empty group can happen: null_parent, or all children freed. */
- if (unlikely(!group->first_child)) {
- assert(group == &children->group);
- /* This hits on first child appended to null parent. */
- if (unlikely(!atexit_set)) {
- atexit(unlink_null);
- atexit_set = true;
- }
- /* Link group into this child, make it the first one. */
- group->hdr.next = child->prop;
- child->prop = &group->hdr;
- group->first_child = child;
-
- /* Child links to itself. */
- child->next = child;
- return true;
- }
-
- if (unlikely(hash_pointer(child, 0) % GROUP_NODE_AVERAGE == 0)) {
- struct group *newgroup;
-
- newgroup = add_group_property(child, children);
- if (likely(newgroup)) {
- list_add(&children->group.list, &newgroup->list.n);
-
- /* Child links to itself. */
- child->next = child;
- return true;
- }
- /* Fall through: on allocation failure reuse old group. */
- }
-
- /* We insert after head, otherwise we'd need to find end. */
- child->next = group->first_child->next;
- group->first_child->next = child;