mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
apply the modified style
This commit is contained in:
@@ -35,12 +35,12 @@
|
||||
* The right child is index*2+1.
|
||||
*/
|
||||
#define heap_parent(i) ((i) >> 1)
|
||||
#define heap_left(i) ((i) << 1)
|
||||
#define heap_left(i) ((i) << 1)
|
||||
/*@}*/
|
||||
|
||||
#define SIZE_INCREMENT 1024
|
||||
|
||||
#define HEAP_MAGIC ISC_MAGIC('H', 'E', 'A', 'P')
|
||||
#define HEAP_MAGIC ISC_MAGIC('H', 'E', 'A', 'P')
|
||||
#define VALID_HEAP(h) ISC_MAGIC_VALID(h, HEAP_MAGIC)
|
||||
|
||||
/*%
|
||||
@@ -54,20 +54,19 @@
|
||||
|
||||
/*% ISC heap structure. */
|
||||
struct isc_heap {
|
||||
unsigned int magic;
|
||||
isc_mem_t * mctx;
|
||||
unsigned int size;
|
||||
unsigned int size_increment;
|
||||
unsigned int last;
|
||||
void ** array;
|
||||
unsigned int magic;
|
||||
isc_mem_t *mctx;
|
||||
unsigned int size;
|
||||
unsigned int size_increment;
|
||||
unsigned int last;
|
||||
void **array;
|
||||
isc_heapcompare_t compare;
|
||||
isc_heapindex_t index;
|
||||
isc_heapindex_t index;
|
||||
};
|
||||
|
||||
#ifdef ISC_HEAP_CHECK
|
||||
static void
|
||||
heap_check(isc_heap_t *heap)
|
||||
{
|
||||
heap_check(isc_heap_t *heap) {
|
||||
unsigned int i;
|
||||
for (i = 1; i <= heap->last; i++) {
|
||||
INSIST(HEAPCONDITION(i));
|
||||
@@ -79,8 +78,7 @@ heap_check(isc_heap_t *heap)
|
||||
|
||||
isc_result_t
|
||||
isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare, isc_heapindex_t idx,
|
||||
unsigned int size_increment, isc_heap_t **heapp)
|
||||
{
|
||||
unsigned int size_increment, isc_heap_t **heapp) {
|
||||
isc_heap_t *heap;
|
||||
|
||||
REQUIRE(heapp != NULL && *heapp == NULL);
|
||||
@@ -107,8 +105,7 @@ isc_heap_create(isc_mem_t *mctx, isc_heapcompare_t compare, isc_heapindex_t idx,
|
||||
}
|
||||
|
||||
void
|
||||
isc_heap_destroy(isc_heap_t **heapp)
|
||||
{
|
||||
isc_heap_destroy(isc_heap_t **heapp) {
|
||||
isc_heap_t *heap;
|
||||
|
||||
REQUIRE(heapp != NULL);
|
||||
@@ -125,9 +122,8 @@ isc_heap_destroy(isc_heap_t **heapp)
|
||||
}
|
||||
|
||||
static bool
|
||||
resize(isc_heap_t *heap)
|
||||
{
|
||||
void ** new_array;
|
||||
resize(isc_heap_t *heap) {
|
||||
void **new_array;
|
||||
unsigned int new_size;
|
||||
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
@@ -146,12 +142,12 @@ resize(isc_heap_t *heap)
|
||||
}
|
||||
|
||||
static void
|
||||
float_up(isc_heap_t *heap, unsigned int i, void *elt)
|
||||
{
|
||||
float_up(isc_heap_t *heap, unsigned int i, void *elt) {
|
||||
unsigned int p;
|
||||
|
||||
for (p = heap_parent(i); i > 1 && heap->compare(elt, heap->array[p]);
|
||||
i = p, p = heap_parent(i)) {
|
||||
i = p, p = heap_parent(i))
|
||||
{
|
||||
heap->array[i] = heap->array[p];
|
||||
if (heap->index != NULL) {
|
||||
(heap->index)(heap->array[i], i);
|
||||
@@ -167,8 +163,7 @@ float_up(isc_heap_t *heap, unsigned int i, void *elt)
|
||||
}
|
||||
|
||||
static void
|
||||
sink_down(isc_heap_t *heap, unsigned int i, void *elt)
|
||||
{
|
||||
sink_down(isc_heap_t *heap, unsigned int i, void *elt) {
|
||||
unsigned int j, size, half_size;
|
||||
size = heap->last;
|
||||
half_size = size / 2;
|
||||
@@ -198,8 +193,7 @@ sink_down(isc_heap_t *heap, unsigned int i, void *elt)
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
isc_heap_insert(isc_heap_t *heap, void *elt)
|
||||
{
|
||||
isc_heap_insert(isc_heap_t *heap, void *elt) {
|
||||
unsigned int new_last;
|
||||
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
@@ -218,10 +212,9 @@ isc_heap_insert(isc_heap_t *heap, void *elt)
|
||||
}
|
||||
|
||||
void
|
||||
isc_heap_delete(isc_heap_t *heap, unsigned int idx)
|
||||
{
|
||||
isc_heap_delete(isc_heap_t *heap, unsigned int idx) {
|
||||
void *elt;
|
||||
bool less;
|
||||
bool less;
|
||||
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
REQUIRE(idx >= 1 && idx <= heap->last);
|
||||
@@ -250,8 +243,7 @@ isc_heap_delete(isc_heap_t *heap, unsigned int idx)
|
||||
}
|
||||
|
||||
void
|
||||
isc_heap_increased(isc_heap_t *heap, unsigned int idx)
|
||||
{
|
||||
isc_heap_increased(isc_heap_t *heap, unsigned int idx) {
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
REQUIRE(idx >= 1 && idx <= heap->last);
|
||||
|
||||
@@ -259,8 +251,7 @@ isc_heap_increased(isc_heap_t *heap, unsigned int idx)
|
||||
}
|
||||
|
||||
void
|
||||
isc_heap_decreased(isc_heap_t *heap, unsigned int idx)
|
||||
{
|
||||
isc_heap_decreased(isc_heap_t *heap, unsigned int idx) {
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
REQUIRE(idx >= 1 && idx <= heap->last);
|
||||
|
||||
@@ -268,8 +259,7 @@ isc_heap_decreased(isc_heap_t *heap, unsigned int idx)
|
||||
}
|
||||
|
||||
void *
|
||||
isc_heap_element(isc_heap_t *heap, unsigned int idx)
|
||||
{
|
||||
isc_heap_element(isc_heap_t *heap, unsigned int idx) {
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
REQUIRE(idx >= 1);
|
||||
|
||||
@@ -281,8 +271,7 @@ isc_heap_element(isc_heap_t *heap, unsigned int idx)
|
||||
}
|
||||
|
||||
void
|
||||
isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap)
|
||||
{
|
||||
isc_heap_foreach(isc_heap_t *heap, isc_heapaction_t action, void *uap) {
|
||||
unsigned int i;
|
||||
|
||||
REQUIRE(VALID_HEAP(heap));
|
||||
|
Reference in New Issue
Block a user