523
524 return (0);
525 }
526
527 /*
528 * Frees all memory allocated for an nvpair (like embedded lists) with
529 * the exception of the nvpair buffer itself.
530 */
531 static void
532 nvpair_free(nvpair_t *nvp)
533 {
534 switch (NVP_TYPE(nvp)) {
535 case DATA_TYPE_NVLIST:
536 nvlist_free(EMBEDDED_NVL(nvp));
537 break;
538 case DATA_TYPE_NVLIST_ARRAY: {
539 nvlist_t **nvlp = EMBEDDED_NVL_ARRAY(nvp);
540 int i;
541
542 for (i = 0; i < NVP_NELEM(nvp); i++)
543 if (nvlp[i] != NULL)
544 nvlist_free(nvlp[i]);
545 break;
546 }
547 default:
548 break;
549 }
550 }
551
552 /*
553 * nvlist_free - free an unpacked nvlist
554 */
555 void
556 nvlist_free(nvlist_t *nvl)
557 {
558 nvpriv_t *priv;
559 i_nvp_t *curr;
560
561 if (nvl == NULL ||
562 (priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL)
563 return;
|
523
524 return (0);
525 }
526
527 /*
528 * Frees all memory allocated for an nvpair (like embedded lists) with
529 * the exception of the nvpair buffer itself.
530 */
531 static void
532 nvpair_free(nvpair_t *nvp)
533 {
534 switch (NVP_TYPE(nvp)) {
535 case DATA_TYPE_NVLIST:
536 nvlist_free(EMBEDDED_NVL(nvp));
537 break;
538 case DATA_TYPE_NVLIST_ARRAY: {
539 nvlist_t **nvlp = EMBEDDED_NVL_ARRAY(nvp);
540 int i;
541
542 for (i = 0; i < NVP_NELEM(nvp); i++)
543 nvlist_free(nvlp[i]);
544 break;
545 }
546 default:
547 break;
548 }
549 }
550
551 /*
552 * nvlist_free - free an unpacked nvlist
553 */
554 void
555 nvlist_free(nvlist_t *nvl)
556 {
557 nvpriv_t *priv;
558 i_nvp_t *curr;
559
560 if (nvl == NULL ||
561 (priv = (nvpriv_t *)(uintptr_t)nvl->nvl_priv) == NULL)
562 return;
|