Description

These functions add a new name-value pair to an nvlist_t. The uniqueness
of nvpair name and data types follows the nvflag argument specified for
nvlist_alloc(). See nvlist_alloc(3NVPAIR).

If NV_UNIQUE_NAME was specified for nvflag, existing nvpairs with matching names are
removed before the new nvpair is added.

If NV_UNIQUE_NAME_TYPE was specified for nvflag, existing nvpairs with matching names and
data types are removed before the new nvpair is added.

If neither was specified for nvflag, the new nvpair is unconditionally added
at the end of the list. The library preserves the order of
the name-value pairs across packing, unpacking, and duplication.

Multiple threads can simultaneously read the same nvlist_t, but only one thread
can actively change a given nvlist_t at a time. The caller is
responsible for the synchronization.

The list that is added to the parent nvlist_t by calling nvlist_add_nvlist()
is copied and thus is not freed when nvlist_free() is called on
the parent list. To prevent memory leaks, your code needs to look
like the following (error handling elided for clarity):