From: Cliff Woolley Date: Wed, 14 Aug 2002 00:07:44 +0000 (+0000) Subject: standardize the syntax here X-Git-Tag: AGB_BEFORE_AAA_CHANGES~269 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8f59c5558b7941fbc207442478b9f30aa6ec333;p=apache standardize the syntax here git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96369 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/experimental/cache_pqueue.c b/modules/experimental/cache_pqueue.c index 02dcec5bde..fbedfe75df 100644 --- a/modules/experimental/cache_pqueue.c +++ b/modules/experimental/cache_pqueue.c @@ -81,14 +81,14 @@ struct cache_pqueue_t apr_ssize_t size; apr_ssize_t avail; apr_ssize_t step; - cache_pqueue_get_priority* pri; - cache_pqueue_getpos* get; - cache_pqueue_setpos* set; + cache_pqueue_get_priority pri; + cache_pqueue_getpos get; + cache_pqueue_setpos set; void **d; }; cache_pqueue_t *cache_pq_init(apr_ssize_t n, - cache_pqueue_get_priority* pri, + cache_pqueue_get_priority pri, cache_pqueue_getpos get, cache_pqueue_setpos set) { @@ -250,31 +250,16 @@ apr_status_t cache_pq_remove(cache_pqueue_t *q, void *d) void *cache_pq_pop(cache_pqueue_t *q) { - void *tmp; - void *d; - int i = 1; - int j; + void *head; if (!q || q->size == 1) return NULL; - d = q->d[1]; - tmp = q->d[--q->size]; - while (i <= q->size / 2) { - j = 2 * i; - if (j < q->size && q->pri(q->d[j]) < q->pri(q->d[j + 1])) { - j++; - } - if (q->pri(q->d[j]) <= q->pri(tmp)) { - break; - } - q->d[i] = q->d[j]; - q->set(q->d[i], i); - i = j; - } - q->d[i] = tmp; - q->set(q->d[i], i); - return d; + head = q->d[1]; + q->d[1] = q->d[--q->size]; + cache_pq_percolate_down(q, 1); + + return head; } void *cache_pq_peek(cache_pqueue_t *q) diff --git a/modules/experimental/cache_pqueue.h b/modules/experimental/cache_pqueue.h index f3efea4878..14d2ccad6c 100644 --- a/modules/experimental/cache_pqueue.h +++ b/modules/experimental/cache_pqueue.h @@ -78,21 +78,21 @@ typedef struct cache_pqueue_t cache_pqueue_t; * @param a the element * @return the score (the lower the score the longer it is kept int the queue) */ -typedef long cache_pqueue_set_priority(long queue_clock, void*a); -typedef long cache_pqueue_get_priority(void*a); +typedef long (*cache_pqueue_set_priority)(long queue_clock, void *a); +typedef long (*cache_pqueue_get_priority)(void *a); /** callback function to get a position of a element */ -typedef apr_ssize_t cache_pqueue_getpos(void *a); +typedef apr_ssize_t (*cache_pqueue_getpos)(void *a); /** * callback function to set a position of a element * @param a the element * @param pos the position to set it to */ -typedef void cache_pqueue_setpos(void *a, apr_ssize_t pos); +typedef void (*cache_pqueue_setpos)(void *a, apr_ssize_t pos); /** debug callback function to print a entry */ -typedef void cache_pqueue_print_entry(FILE *out, void *a); +typedef void (*cache_pqueue_print_entry)(FILE *out, void *a); /** * initialize the queue @@ -106,7 +106,7 @@ typedef void cache_pqueue_print_entry(FILE *out, void *a); * @Return the handle or NULL for insufficent memory */ cache_pqueue_t *cache_pq_init(apr_ssize_t n, - cache_pqueue_get_priority *pri, + cache_pqueue_get_priority pri, cache_pqueue_getpos get, cache_pqueue_setpos set); /**