diff options
author | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 05:51:47 +0000 |
---|---|---|
committer | rgrimes <rgrimes@FreeBSD.org> | 1995-05-30 05:51:47 +0000 |
commit | f05428e4cd63dde97bac14b84dd146a5c00455e3 (patch) | |
tree | e1331adb5d216f2b3fa6baa6491752348d2e5f10 /lib/libc/stdlib | |
parent | 6de57e42c294763c78d77b0a9a7c5a08008a378a (diff) | |
download | FreeBSD-src-f05428e4cd63dde97bac14b84dd146a5c00455e3.zip FreeBSD-src-f05428e4cd63dde97bac14b84dd146a5c00455e3.tar.gz |
Remove trailing whitespace.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r-- | lib/libc/stdlib/getsubopt.c | 2 | ||||
-rw-r--r-- | lib/libc/stdlib/malloc.c | 12 | ||||
-rw-r--r-- | lib/libc/stdlib/merge.c | 4 | ||||
-rw-r--r-- | lib/libc/stdlib/qsort.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/radixsort.c | 10 | ||||
-rw-r--r-- | lib/libc/stdlib/random.c | 6 | ||||
-rw-r--r-- | lib/libc/stdlib/setenv.c | 2 | ||||
-rw-r--r-- | lib/libc/stdlib/strhash.c | 103 | ||||
-rw-r--r-- | lib/libc/stdlib/strtoull.c | 2 | ||||
-rw-r--r-- | lib/libc/stdlib/strtouq.c | 2 |
10 files changed, 78 insertions, 71 deletions
diff --git a/lib/libc/stdlib/getsubopt.c b/lib/libc/stdlib/getsubopt.c index d0ebde2..afd577a 100644 --- a/lib/libc/stdlib/getsubopt.c +++ b/lib/libc/stdlib/getsubopt.c @@ -80,7 +80,7 @@ getsubopt(optionp, tokens, valuep) *p = '\0'; for (*valuep = ++p; *p && *p != ',' && *p != ' ' && *p != '\t'; ++p); - if (*p) + if (*p) *p++ = '\0'; } else *p++ = '\0'; diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index ea8f092..26a2b54 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -39,9 +39,9 @@ static char sccsid[] = "@(#)malloc.c 8.1 (Berkeley) 6/4/93"; * malloc.c (Caltech) 2/21/82 * Chris Kingsley, kingsley@cit-20. * - * This is a very fast storage allocator. It allocates blocks of a small + * This is a very fast storage allocator. It allocates blocks of a small * number of different sizes, and keeps free lists of each size. Blocks that - * don't exactly fit are passed up to the next larger size. In this + * don't exactly fit are passed up to the next larger size. In this * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long. * This is designed for use in a virtual memory environment. */ @@ -257,7 +257,7 @@ morecore(bucket) void free(cp) void *cp; -{ +{ register int size; register union overhead *op; @@ -298,9 +298,9 @@ int __realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */ void * realloc(cp, nbytes) - void *cp; + void *cp; size_t nbytes; -{ +{ register u_int onb; register int i; union overhead *op; @@ -389,7 +389,7 @@ findbucket(freep, srchlen) #ifdef MSTATS /* * mstats - print out statistics about malloc - * + * * Prints two lines of numbers, one showing the length of the free list * for each size category, the second showing the number of mallocs - * frees for each size category. diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 7d00844..a47e300 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -80,7 +80,7 @@ static void insertionsort __P((u_char *, size_t, size_t, int (*)())); do \ *dst++ = *src++; \ while (i -= 1) - + /* * Find the next possible pointer head. (Trickery for forcing an array * to do double duty as a linked list when objects do not align with word @@ -164,7 +164,7 @@ EXPONENTIAL: for (i = size; ; i <<= 1) } else if ((*cmp)(q, p) <= sense) { t = p; if (i == size) - big = 0; + big = 0; goto FASTCASE; } else b = p; diff --git a/lib/libc/stdlib/qsort.c b/lib/libc/stdlib/qsort.c index 1d3aa93..49f5349 100644 --- a/lib/libc/stdlib/qsort.c +++ b/lib/libc/stdlib/qsort.c @@ -65,7 +65,7 @@ swapfunc(a, b, n, swaptype) char *a, *b; int n, swaptype; { - if(swaptype <= 1) + if(swaptype <= 1) swapcode(long, a, b, n) else swapcode(char, a, b, n) @@ -151,7 +151,7 @@ loop: SWAPINIT(a, es); } if (swap_cnt == 0) { /* Switch to insertion sort */ for (pm = a + es; pm < (char *) a + n * es; pm += es) - for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; pl -= es) swap(pl, pl - es); return; @@ -164,7 +164,7 @@ loop: SWAPINIT(a, es); vecswap(pb, pn - r, r); if ((r = pb - pa) > es) qsort(a, r / es, es, cmp); - if ((r = pd - pc) > es) { + if ((r = pd - pc) > es) { /* Iterate rather than recurse to save stack space */ a = pn - r; n = r / es; diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index d211f3d..af47fb0 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -3,7 +3,7 @@ * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by - * Peter McIlroy and by Dan Bernstein at New York University, + * Peter McIlroy and by Dan Bernstein at New York University, * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,13 +40,13 @@ static char sccsid[] = "@(#)radixsort.c 8.1 (Berkeley) 6/4/93"; /* * Radixsort routines. - * + * * Program r_sort_a() is unstable but uses O(logN) extra memory for a stack. * Use radixsort(a, n, trace, endchar) for this case. - * + * * For stable sorting (using N extra pointers) use sradixsort(), which calls * r_sort_b(). - * + * * For a description of this code, see D. McIlroy, P. McIlroy, K. Bostic, * "Engineering Radix Sort". */ @@ -294,7 +294,7 @@ r_sort_b(a, ta, n, i, tr, endch) *--top[tr[(*ak)[i]]] = *ak; } } - + static inline void simplesort(a, n, b, tr, endch) /* insertion sort */ register const u_char **a; diff --git a/lib/libc/stdlib/random.c b/lib/libc/stdlib/random.c index 0928a86..fa89f82 100644 --- a/lib/libc/stdlib/random.c +++ b/lib/libc/stdlib/random.c @@ -61,7 +61,7 @@ static char sccsid[] = "@(#)random.c 8.1 (Berkeley) 6/4/93"; * state information, which will allow a degree seven polynomial. (Note: * the zeroeth word of state information also has some other information * stored in it -- see setstate() for details). - * + * * The random number generation technique is a linear feedback shift register * approach, employing trinomials (since there are fewer terms to sum up that * way). In this approach, the least significant bit of all the numbers in @@ -216,12 +216,12 @@ srandom(x) * the break values for the different R.N.G.'s, we choose the best (largest) * one we can and set things up for it. srandom() is then called to * initialize the state information. - * + * * Note that on return from srandom(), we set state[-1] to be the type * multiplexed with the current value of the rear pointer; this is so * successive calls to initstate() won't lose this information and will be * able to restart with setstate(). - * + * * Note: the first thing we do is save the current state, if any, just like * setstate() so that it doesn't matter when initstate is called. * diff --git a/lib/libc/stdlib/setenv.c b/lib/libc/stdlib/setenv.c index b36d673..4a28f25 100644 --- a/lib/libc/stdlib/setenv.c +++ b/lib/libc/stdlib/setenv.c @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93"; #include <stdlib.h> #include <string.h> -char *__findenv __P((const char *, int *)); +char *__findenv __P((const char *, int *)); /* * setenv -- diff --git a/lib/libc/stdlib/strhash.c b/lib/libc/stdlib/strhash.c index 77bc02e..0b50ce0 100644 --- a/lib/libc/stdlib/strhash.c +++ b/lib/libc/stdlib/strhash.c @@ -1,5 +1,5 @@ #ifndef lint -static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.2 1995/03/26 19:32:24 ache Exp $"; +static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.3 1995/03/28 08:41:02 jkh Exp $"; #endif /* @@ -12,12 +12,12 @@ static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.2 19 * * * All rights reserved. - * + * * This is unsupported software and is subject to change without notice. * the author makes no representations about the suitability of this software * for any purpose. It is supplied "as is" without express or implied * warranty. - * + * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that @@ -32,11 +32,18 @@ static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.2 19 * This is a fairly simple open addressing hash scheme. * Terry did all the code, I just did the spec. * Thanks again, you crazy Aussie.. - * + * */ /* * $Log: strhash.c,v $ + * Revision 1.3 1995/03/28 08:41:02 jkh + * Fix a missing _hash() to prevent namespace pollution with the db/hash routines. + * Grrr. If the dbhash routines weren't grossly overengineered I wouldn't + * even need to do this! :-( + * + * Also now export the hash_stats routine. Manpage coming RSN - I promise. + * * Revision 1.2 1995/03/26 19:32:24 ache * Hash 8bit chars without sign extension * @@ -53,35 +60,35 @@ static char *rcsid = "$Header: /home/ncvs/src/lib/libc/stdlib/strhash.c,v 1.2 19 * * Revision 2.0 90/03/26 01:44:26 jkh * pre-beta check-in - * + * * Revision 1.8 90/03/09 19:22:35 jkh * Fixed bogus comment. - * + * * Revision 1.7 90/03/09 19:01:08 jkh * Added comments, GPL. - * + * * Revision 1.6 90/03/08 17:55:58 terry * Rearranged hash_purge to be a tiny bit more efficient. * Added verbose option to hash_stats. - * + * * Revision 1.5 90/03/08 17:19:54 terry * Added hash_purge. Added arg to hash_traverse. Changed all * void * to Generic. - * + * * Revision 1.4 90/03/08 12:02:35 terry * Fixed problems with allocation that I screwed up last night. * Changed bucket lists to be singly linked. Thanks to JKH, my hero. - * + * * Revision 1.3 90/03/07 21:33:33 terry * Cleaned up a few decls to keep gcc -Wall quiet. - * + * * Revision 1.2 90/03/07 21:14:53 terry * Comments. Added HASH_STATS define. Removed hash_find() * and new_node(). - * + * * Revision 1.1 90/03/07 20:49:45 terry * Initial revision - * + * * */ @@ -112,26 +119,26 @@ static hash_node *list_find(caddr_t key, hash_node *head); hash_table * hash_create(int size) { - register int i; + register int i; hash_table *new = (hash_table *)malloc(sizeof(hash_table)); if (!new || size < 0){ return HASH_NULL; } - + if (size == 0){ size = HASH_SZ; } - + if (!(new->buckets = (hash_node **)malloc(size * sizeof(hash_node *)))){ return HASH_NULL; } for (i = 0; i < size; i++){ new->buckets[i] = NODE_NULL; - } + } new->size = size; - + return new; } @@ -166,7 +173,7 @@ _hash(int size, char *key) while (*key){ h = (h << 1) ^ (h ^ (unsigned char) *key++); - } + } h %= size; return h; @@ -179,17 +186,17 @@ _hash(int size, char *key) * The function (*nukefunc)() is in charge of disposing * of the storage help by the data associated with the node. */ -void +void hash_destroy(hash_table *table, char *key, void (*nukefunc)()) { int bucket = _hash(table->size, key); hash_node *found = table->buckets[bucket]; hash_node *to_free = NODE_NULL; - + if (!found) { return; } - + if (!strcmp(found->key, key)) { /* * It was the head of the list. @@ -209,12 +216,12 @@ hash_destroy(hash_table *table, char *key, void (*nukefunc)()) } found = found->next; } - + if (!to_free){ return; } } - + if (nukefunc) (*nukefunc)(to_free->key, to_free->data); free(to_free); @@ -227,8 +234,8 @@ hash_destroy(hash_table *table, char *key, void (*nukefunc)()) * * Search the table for the given key. Then: * - * 1) If you find it and there is no replacement function, just - * return what you found. (This is a simple search). + * 1) If you find it and there is no replacement function, just + * return what you found. (This is a simple search). * 2) If you find it and there is a replacement function, run * the function on the data you found, and replace the old * data with whatever is passed in datum. Return 0. @@ -256,11 +263,11 @@ hash_search(hash_table *table, caddr_t key, void *datum, } else{ if (datum){ - + static int assign_key(); - + hash_node *new = (hash_node *)malloc(sizeof(hash_node)); - + if (!new || !assign_key(key, new)){ return GENERIC_NULL; } @@ -276,7 +283,7 @@ hash_search(hash_table *table, caddr_t key, void *datum, /* * assign_key() * - * Set the key value of a node to be 'key'. Get some space from + * Set the key value of a node to be 'key'. Get some space from * malloc and copy it in etc. Return 1 if all is well, 0 otherwise. */ static int @@ -285,11 +292,11 @@ assign_key(char *key, hash_node *node) if (!node || !key){ return 0; } - + if (!(node->key = (char *)malloc(strlen(key) + 1))){ return 0; } - + node->key[0] = '\0'; strcat(node->key, key); return 1; @@ -304,12 +311,12 @@ assign_key(char *key, hash_node *node) void hash_traverse(hash_table *table, int (*func)(), void *arg) { - register int i; + register int i; register int size = table->size; if (!func) return; - + for (i = 0; i < size; i++) { hash_node *n = table->buckets[i]; while (n) { @@ -317,7 +324,7 @@ hash_traverse(hash_table *table, int (*func)(), void *arg) return; n = n->next; } - } + } return; } @@ -331,9 +338,9 @@ hash_traverse(hash_table *table, int (*func)(), void *arg) void hash_purge(hash_table *table, void (*purge_func)(char *p1, void *p2)) { - register int i; + register int i; register int size = table->size; - + for (i = 0; i < size; i++) { hash_node *n = table->buckets[i]; if (n) { @@ -347,7 +354,7 @@ hash_purge(hash_table *table, void (*purge_func)(char *p1, void *p2)) } while (n); table->buckets[i] = NODE_NULL; } - } + } } #undef min @@ -361,19 +368,19 @@ hash_purge(hash_table *table, void (*purge_func)(char *p1, void *p2)) void hash_stats(hash_table *table, int verbose) { - register int i; + register int i; int total_elements = 0; int non_empty_buckets = 0; int max_count = 0; int max_repeats = 0; int *counts; int size = table->size; - + if (!(counts = (int *)malloc(size * sizeof(int)))){ fprintf(stderr, "malloc returns 0\n"); - exit(1); + exit(1); } - + for (i = 0; i < size; i++){ int x = 0; hash_node *n = table->buckets[i]; @@ -392,7 +399,7 @@ hash_stats(hash_table *table, int verbose) counts[i]++; n = n->next; } - + total_elements += counts[i]; if (counts[i] > max_count){ max_count = counts[i]; @@ -401,17 +408,17 @@ hash_stats(hash_table *table, int verbose) else if (counts[i] == max_count){ max_repeats++; } - + if (counts[i] && verbose){ printf(" (%d)\n", counts[i]); } - } - + } + printf("\n"); printf("%d element%s in storage.\n", total_elements, total_elements == 1 ? "" : "s"); - + if (total_elements){ - printf("%d of %d (%.2f%%) buckets are in use\n", non_empty_buckets, size, + printf("%d of %d (%.2f%%) buckets are in use\n", non_empty_buckets, size, (double)100 * (double)non_empty_buckets / (double)(size)); printf("the maximum number of elements in a bucket is %d (%d times)\n", max_count, max_repeats); printf("average per bucket is %f\n", (double)total_elements / (double)non_empty_buckets); diff --git a/lib/libc/stdlib/strtoull.c b/lib/libc/stdlib/strtoull.c index cc62a07..ee1e13b 100644 --- a/lib/libc/stdlib/strtoull.c +++ b/lib/libc/stdlib/strtoull.c @@ -70,7 +70,7 @@ strtouq(nptr, endptr, base) if (c == '-') { neg = 1; c = *s++; - } else { + } else { neg = 0; if (c == '+') c = *s++; diff --git a/lib/libc/stdlib/strtouq.c b/lib/libc/stdlib/strtouq.c index cc62a07..ee1e13b 100644 --- a/lib/libc/stdlib/strtouq.c +++ b/lib/libc/stdlib/strtouq.c @@ -70,7 +70,7 @@ strtouq(nptr, endptr, base) if (c == '-') { neg = 1; c = *s++; - } else { + } else { neg = 0; if (c == '+') c = *s++; |