FreeBSD/cddl/contrib/opensolaris/cmd/zpool/zpool_iter.c
/*
 * Callback function for pool_list_get().  Adds the given pool to the AVL tree
 * of known pools.
 */
Callback function for pool_list_get().  Adds the given pool to the AVL tree
of known pools.
Callback function for pool_list_get () . Adds the given pool to the AVL tree of known pools .
static int
add_pool(zpool_handle_t *zhp, void *data)
{
	zpool_list_t *zlp = data;
	zpool_node_t *node = safe_malloc(sizeof (zpool_node_t));
	uu_avl_index_t idx;
	node->zn_handle = zhp;
	uu_avl_node_init(node, &node->zn_avlnode, zlp->zl_pool);
	if (uu_avl_find(zlp->zl_avl, node, NULL, &idx) == NULL) {
		if (zlp->zl_proplist &&
		    zpool_expand_proplist(zhp, zlp->zl_proplist) != 0) {
			zpool_close(zhp);
			free(node);
			return (-1);
		}
		uu_avl_insert(zlp->zl_avl, node, idx);
	} else {
		zpool_close(zhp);
		free(node);
		return (-1);
	}
	return (0);
}
static int add_pool ( zpool_handle_t * zhp , void * data ) { zpool_list_t * zlp = data ; zpool_node_t * node = safe_malloc ( sizeof ( zpool_node_t ) ) ; uu_avl_index_t idx ; node -> zn_handle = zhp ; uu_avl_node_init ( node , & node -> zn_avlnode , zlp -> zl_pool ) ; if ( uu_avl_find ( zlp -> zl_avl , node , NULL , & idx ) == NULL ) { if ( zlp -> zl_proplist && zpool_expand_proplist ( zhp , zlp -> zl_proplist ) != 0 ) { zpool_close ( zhp ) ; free ( node ) ; return ( -1 ) ; } uu_avl_insert ( zlp -> zl_avl , node , idx ) ; } else { zpool_close ( zhp ) ; free ( node ) ; return ( -1 ) ; } return ( 0 ) ; }
Callback function for pool_list_get().
Callback function for pool_list_get () .