summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2002-02-27 20:26:38 +0000
committerMarc Espie <espie@cvs.openbsd.org>2002-02-27 20:26:38 +0000
commit545015bf9f9b46354ec6d9037a0d11a4442b128c (patch)
treea39196198237c739f24d8257f2badc17e2fc591c /usr.bin
parent0c21c07057014d40ce7fa7b78347a924816c19da (diff)
ANSI decls. okay millert@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tsort/tsort.c115
1 files changed, 31 insertions, 84 deletions
diff --git a/usr.bin/tsort/tsort.c b/usr.bin/tsort/tsort.c
index 22154bfac9e..d6ae0772cc2 100644
--- a/usr.bin/tsort/tsort.c
+++ b/usr.bin/tsort/tsort.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tsort.c,v 1.13 2002/02/17 19:42:33 millert Exp $ */
+/* $OpenBSD: tsort.c,v 1.14 2002/02/27 20:26:37 espie Exp $ */
/* ex:ts=8 sw=4:
*/
@@ -179,8 +179,7 @@ int main(int, char *[]);
***/
static void *
-emem(p)
- void *p;
+emem(void *p)
{
if (p)
return p;
@@ -189,33 +188,25 @@ emem(p)
}
static void *
-hash_alloc(s, u)
- size_t s;
- void *u UNUSED;
+hash_alloc(size_t s, void *u UNUSED)
{
return emem(calloc(s, 1));
}
static void
-hash_free(p, s, u)
- void *p;
- size_t s UNUSED;
- void *u UNUSED;
+hash_free(void *p, size_t s UNUSED, void *u UNUSED)
{
free(p);
}
static void *
-entry_alloc(s, u)
- size_t s;
- void *u UNUSED;
+entry_alloc(size_t s, void *u UNUSED)
{
return emalloc(s);
}
static void *
-emalloc(s)
- size_t s;
+emalloc(size_t s)
{
return emem(malloc(s));
}
@@ -228,9 +219,7 @@ emalloc(s)
/* Inserting and finding nodes in the hash structure.
* We handle interval strings for efficiency wrt fgetln. */
static struct node *
-new_node(start, end)
- const char *start;
- const char *end;
+new_node(const char *start, const char *end)
{
struct node *n;
@@ -246,17 +235,13 @@ new_node(start, end)
static void
-nodes_init(h)
- struct ohash *h;
+nodes_init(struct ohash *h)
{
ohash_init(h, HASH_START, &node_info);
}
static struct node *
-node_lookup(h, start, end)
- struct ohash *h;
- const char *start;
- const char *end;
+node_lookup(struct ohash *h, const char *start, const char *end)
{
unsigned int i;
struct node * n;
@@ -271,8 +256,7 @@ node_lookup(h, start, end)
#ifdef DEBUG
static void
-dump_node(n)
- struct node *n;
+dump_node(struct node *n)
{
struct link *l;
@@ -286,8 +270,7 @@ dump_node(n)
}
static void
-dump_array(a)
- struct array *a;
+dump_array(struct array *a)
{
unsigned int i;
@@ -296,8 +279,7 @@ dump_array(a)
}
static void
-dump_hash(h)
- struct ohash *h;
+dump_hash(struct ohash *h)
{
unsigned int i;
struct node *n;
@@ -313,8 +295,7 @@ dump_hash(h)
***/
static void
-insert_arc(a, b)
- struct node *a, *b;
+insert_arc(struct node *a, struct node *b)
{
struct link *l;
@@ -331,13 +312,8 @@ insert_arc(a, b)
}
static unsigned int
-read_pairs(f, h, reverse, name, order, hint)
- FILE *f;
- struct ohash *h;
- int reverse;
- const char *name;
- unsigned int order;
- int hint;
+read_pairs(FILE *f, struct ohash *h, int reverse, const char *name,
+ unsigned int order, int hint)
{
int toggle;
struct node *a;
@@ -388,12 +364,8 @@ read_pairs(f, h, reverse, name, order, hint)
}
static unsigned int
-read_hints(f, h, quiet, name, order)
- FILE *f;
- struct ohash *h;
- int quiet;
- const char *name;
- unsigned int order;
+read_hints(FILE *f, struct ohash *h, int quiet, const char *name,
+ unsigned int order)
{
char *str;
size_t size;
@@ -432,9 +404,7 @@ read_hints(f, h, quiet, name, order)
***/
static void
-heap_down(h, i)
- struct array *h;
- unsigned int i;
+heap_down(struct array *h, unsigned int i)
{
unsigned int j;
struct node *swap;
@@ -451,9 +421,7 @@ heap_down(h, i)
}
static void
-heapify(h, verbose)
- struct array *h;
- int verbose;
+heapify(struct array *h, int verbose)
{
unsigned int i;
@@ -467,8 +435,7 @@ heapify(h, verbose)
#define DEQUEUE(h) ( hints_flag ? dequeue(h) : (h)->t[--(h)->entries] )
static struct node *
-dequeue(h)
- struct array *h;
+dequeue(struct array *h)
{
struct node *n;
@@ -492,9 +459,7 @@ dequeue(h)
} while(0);
static void
-enqueue(h, n)
- struct array *h;
- struct node *n;
+enqueue(struct array *h, struct node *n)
{
unsigned int i, j;
struct node *swap;
@@ -514,8 +479,7 @@ enqueue(h, n)
* Iterate until no nodes are left.
*/
static void
-make_transparent(hash)
- struct ohash *hash;
+make_transparent(struct ohash *hash)
{
struct node *n;
unsigned int i;
@@ -571,10 +535,7 @@ make_transparent(hash)
/* Split nodes into unrefed nodes/live nodes. */
static void
-split_nodes(hash, heap, remaining)
- struct ohash *hash;
- struct array *heap;
- struct array *remaining;
+split_nodes(struct ohash *hash, struct array *heap, struct array *remaining)
{
struct node *n;
@@ -595,8 +556,7 @@ split_nodes(hash, heap, remaining)
/* Good point to break a cycle: live node with as few refs as possible. */
static struct node *
-find_good_cycle_break(h)
- struct array *h;
+find_good_cycle_break(struct array *h)
{
unsigned int i;
unsigned int best;
@@ -622,8 +582,7 @@ find_good_cycle_break(h)
/* Retrieve the node with the smallest order. */
static struct node *
-find_smallest_node(h)
- struct array *h;
+find_smallest_node(struct array *h)
{
unsigned int i;
unsigned int best;
@@ -652,9 +611,7 @@ find_smallest_node(h)
/* Explore the nodes reachable from i to find a cycle, store it in c.
* This may fail. */
static struct node *
-find_cycle_from(i, c)
- struct node *i;
- struct array *c;
+find_cycle_from(struct node *i, struct array *c)
{
struct node *n;
@@ -702,9 +659,7 @@ find_cycle_from(i, c)
* to go through the whole array, but it is not needed often.
*/
static struct node *
-find_predecessor(a, n)
- struct array *a;
- struct node *n;
+find_predecessor(struct array *a, struct node *n)
{
unsigned int i;
@@ -729,10 +684,7 @@ find_predecessor(a, n)
Update the largest cycle found so far.
*/
static unsigned int
-traverse_node(n, o, c)
- struct node *n;
- unsigned int o;
- struct array *c;
+traverse_node(struct node *n, unsigned int o, struct array *c)
{
unsigned int min, max;
@@ -797,8 +749,7 @@ traverse_node(n, o, c)
}
static void
-print_cycle(c)
- struct array *c;
+print_cycle(struct array *c)
{
unsigned int i;
@@ -811,9 +762,7 @@ print_cycle(c)
}
static struct node *
-find_longest_cycle(h, c)
- struct array *h;
- struct array *c;
+find_longest_cycle(struct array *h, struct array *c)
{
unsigned int i;
unsigned int o;
@@ -863,9 +812,7 @@ find_longest_cycle(h, c)
#define plural(n) ((n) > 1 ? "s" : "")
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
struct ohash pairs;
int reverse_flag, quiet_flag, long_flag,