e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * CDDL HEADER START
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * This file and its contents are supplied under the terms of the
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Common Development and Distribution License ("CDDL"), version 1.0.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * You may only use this file in accordance with the terms of version
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * 1.0 of the CDDL.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * A full copy of the text of the CDDL should have accompanied this
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * source. A copy of the CDDL is also available via the Internet at
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * CDDL HEADER END
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Copyright (c) 2012 by Delphix. All rights reserved.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Create a new priority queue.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * size is the maximum number of items that will be stored in the priority
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * queue at one time.
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhaldt_pq_init(dtrace_hdl_t *dtp, uint_t size, dt_pq_value_f value_cb, void *cb_arg)
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal if ((p = dt_zalloc(dtp, sizeof (dt_pq_t))) == NULL)
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal p->dtpq_items = dt_zalloc(dtp, size * sizeof (p->dtpq_items[0]));
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal return (p->dtpq_value(item, p->dtpq_arg));
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal while (i > 1 && dt_pq_getvalue(p, i) < dt_pq_getvalue(p, i / 2)) {
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * Return elements from the priority queue. *cookie should be zero when first
e5803b76927480e8f9b67b22201c484ccf4c2bcfAdam H. Leventhal * called. Returns NULL when there are no more elements.