summaryrefslogtreecommitdiffstats
path: root/lib/isc/heap.c
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2009-05-31 00:11:36 +0000
committerdougb <dougb@FreeBSD.org>2009-05-31 00:11:36 +0000
commitfd553238c94c3abfef11bfdfc5cb05b32cbe5f76 (patch)
tree72d567a9bc3fb8adcfcbaa9baedc122d53071209 /lib/isc/heap.c
parentd342cb576b0154d48c90bc32e251331282264cd4 (diff)
downloadFreeBSD-src-fd553238c94c3abfef11bfdfc5cb05b32cbe5f76.zip
FreeBSD-src-fd553238c94c3abfef11bfdfc5cb05b32cbe5f76.tar.gz
Vendor import of BIND 9.6.1rc1
Diffstat (limited to 'lib/isc/heap.c')
-rw-r--r--lib/isc/heap.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/isc/heap.c b/lib/isc/heap.c
index 9c495a7..91d78c0 100644
--- a/lib/isc/heap.c
+++ b/lib/isc/heap.c
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1997-2001 Internet Software Consortium.
*
- * Permission to use, copy, modify, and distribute this software for any
+ * Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: heap.c,v 1.30.18.3 2006/04/17 18:27:33 explorer Exp $ */
+/* $Id: heap.c,v 1.37 2007/10/19 17:15:53 explorer Exp $ */
/*! \file
* Heap implementation of priority queues adapted from the following:
@@ -208,9 +208,13 @@ isc_heap_delete(isc_heap_t *heap, unsigned int index) {
REQUIRE(index >= 1 && index <= heap->last);
if (index == heap->last) {
+ heap->array[heap->last] = NULL;
heap->last--;
} else {
- elt = heap->array[heap->last--];
+ elt = heap->array[heap->last];
+ heap->array[heap->last] = NULL;
+ heap->last--;
+
less = heap->compare(elt, heap->array[index]);
heap->array[index] = elt;
if (less)
@@ -239,9 +243,11 @@ isc_heap_decreased(isc_heap_t *heap, unsigned int index) {
void *
isc_heap_element(isc_heap_t *heap, unsigned int index) {
REQUIRE(VALID_HEAP(heap));
- REQUIRE(index >= 1 && index <= heap->last);
+ REQUIRE(index >= 1);
- return (heap->array[index]);
+ if (index <= heap->last)
+ return (heap->array[index]);
+ return (NULL);
}
void
OpenPOWER on IntegriCloud