MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nvpair_free

Function nvpair_free

freebsd/contrib/libnv/bsd_nvpair.c:2040–2089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2038#endif
2039
2040void
2041nvpair_free(nvpair_t *nvp)
2042{
2043 size_t i;
2044
2045 NVPAIR_ASSERT(nvp);
2046 PJDLOG_ASSERT(nvp->nvp_list == NULL);
2047
2048 nvp->nvp_magic = 0;
2049 switch (nvp->nvp_type) {
2050#ifndef _KERNEL
2051 case NV_TYPE_DESCRIPTOR:
2052 close((int)nvp->nvp_data);
2053 break;
2054 case NV_TYPE_DESCRIPTOR_ARRAY:
2055 for (i = 0; i < nvp->nvp_nitems; i++)
2056 close(((int *)(intptr_t)nvp->nvp_data)[i]);
2057 nv_free((int *)(intptr_t)nvp->nvp_data);
2058 break;
2059#endif
2060 case NV_TYPE_NVLIST:
2061 nvlist_destroy((nvlist_t *)(intptr_t)nvp->nvp_data);
2062 break;
2063 case NV_TYPE_STRING:
2064 nv_free((char *)(intptr_t)nvp->nvp_data);
2065 break;
2066 case NV_TYPE_BINARY:
2067 nv_free((void *)(intptr_t)nvp->nvp_data);
2068 break;
2069 case NV_TYPE_NVLIST_ARRAY:
2070 for (i = 0; i < nvp->nvp_nitems; i++) {
2071 nvlist_destroy(
2072 ((nvlist_t **)(intptr_t)nvp->nvp_data)[i]);
2073 }
2074 nv_free(((nvlist_t **)(intptr_t)nvp->nvp_data));
2075 break;
2076 case NV_TYPE_NUMBER_ARRAY:
2077 nv_free((uint64_t *)(intptr_t)nvp->nvp_data);
2078 break;
2079 case NV_TYPE_BOOL_ARRAY:
2080 nv_free((bool *)(intptr_t)nvp->nvp_data);
2081 break;
2082 case NV_TYPE_STRING_ARRAY:
2083 for (i = 0; i < nvp->nvp_nitems; i++)
2084 nv_free(((char **)(intptr_t)nvp->nvp_data)[i]);
2085 nv_free((char **)(intptr_t)nvp->nvp_data);
2086 break;
2087 }
2088 nv_free(nvp);
2089}
2090
2091void
2092nvpair_free_structure(nvpair_t *nvp)

Callers 4

nvlist_destroyFunction · 0.70
NVLIST_APPEND_ARRAYFunction · 0.70
nvlist_free_nvpairFunction · 0.70

Calls 2

nvlist_destroyFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected