Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/rcorder KNF, remove unnecessary crap, ...



details:   https://anonhg.NetBSD.org/src/rev/f35cc4ae1a2e
branches:  trunk
changeset: 533447:f35cc4ae1a2e
user:      lukem <lukem%NetBSD.org@localhost>
date:      Sun Jun 30 14:17:44 2002 +0000

description:
KNF, remove unnecessary crap, ...

diffstat:

 sbin/rcorder/Makefile  |    5 +-
 sbin/rcorder/ealloc.c  |   28 +++----
 sbin/rcorder/ealloc.h  |   10 +-
 sbin/rcorder/hash.c    |  106 +++++++++++++--------------
 sbin/rcorder/hash.h    |   24 ++---
 sbin/rcorder/rcorder.c |  189 ++++++++++++++----------------------------------
 sbin/rcorder/sprite.h  |  113 -----------------------------
 7 files changed, 138 insertions(+), 337 deletions(-)

diffs (truncated from 934 to 300 lines):

diff -r b914136700b4 -r f35cc4ae1a2e sbin/rcorder/Makefile
--- a/sbin/rcorder/Makefile     Sun Jun 30 13:31:15 2002 +0000
+++ b/sbin/rcorder/Makefile     Sun Jun 30 14:17:44 2002 +0000
@@ -1,4 +1,4 @@
-#       $NetBSD: Makefile,v 1.2 1999/11/23 05:50:08 mrg Exp $
+#       $NetBSD: Makefile,v 1.3 2002/06/30 14:17:44 lukem Exp $
 
 PROG=   rcorder
 SRCS=   ealloc.c hash.c rcorder.c
@@ -7,7 +7,6 @@
 LDADD+=        -lutil
 DPADD+=        ${LIBUTIL}
 
-# XXX hack for make's hash.[ch]
-CPPFLAGS+= -DORDER
+WARNS?=        3
 
 .include <bsd.prog.mk>
diff -r b914136700b4 -r f35cc4ae1a2e sbin/rcorder/ealloc.c
--- a/sbin/rcorder/ealloc.c     Sun Jun 30 13:31:15 2002 +0000
+++ b/sbin/rcorder/ealloc.c     Sun Jun 30 14:17:44 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ealloc.c,v 1.1 1999/11/23 05:28:20 mrg Exp $   */
+/*     $NetBSD: ealloc.c,v 1.2 2002/06/30 14:17:44 lukem Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ealloc.c,v 1.1 1999/11/23 05:28:20 mrg Exp $");
+__RCSID("$NetBSD: ealloc.c,v 1.2 2002/06/30 14:17:44 lukem Exp $");
 #endif /* not lint */
 
 #include <stdio.h>
@@ -50,15 +50,16 @@
 
 #include "ealloc.h"
 
-static void enomem __P((void));
+static void enomem(void);
 
 /*
  * enomem --
  *     die when out of memory.
  */
 static void
-enomem()
+enomem(void)
 {
+
        errx(2, "Cannot allocate memory.");
 }
 
@@ -67,10 +68,9 @@
  *     malloc, but die on error.
  */
 void *
-emalloc(len)
-       size_t len;
+emalloc(size_t len)
 {
-       void *p;
+       void    *p;
 
        if ((p = malloc(len)) == NULL)
                enomem();
@@ -82,10 +82,9 @@
  *     strdup, but die on error.
  */
 char *
-estrdup(str)
-       const char *str;
+estrdup(const char *str)
 {
-       char *p;
+       char    *p;
 
        if ((p = strdup(str)) == NULL)
                enomem();
@@ -97,10 +96,9 @@
  *     realloc, but die on error.
  */
 void *
-erealloc(ptr, size)
-       void *ptr;
-       size_t size;
+erealloc(void *ptr, size_t size)
 {
+
        if ((ptr = realloc(ptr, size)) == NULL)
                enomem();
        return(ptr);
@@ -111,9 +109,7 @@
  *     calloc, but die on error.
  */
 void *
-ecalloc(nmemb, size)
-       size_t nmemb;
-       size_t size;
+ecalloc(size_t nmemb, size_t size)
 {
        void    *ptr;
 
diff -r b914136700b4 -r f35cc4ae1a2e sbin/rcorder/ealloc.h
--- a/sbin/rcorder/ealloc.h     Sun Jun 30 13:31:15 2002 +0000
+++ b/sbin/rcorder/ealloc.h     Sun Jun 30 14:17:44 2002 +0000
@@ -1,6 +1,6 @@
-/*     $NetBSD: ealloc.h,v 1.1 1999/11/23 05:28:20 mrg Exp $   */
+/*     $NetBSD: ealloc.h,v 1.2 2002/06/30 14:17:44 lukem Exp $ */
 
-void   *emalloc __P((size_t len));
-char   *estrdup __P((const char *str));
-void   *erealloc __P((void *ptr, size_t size));
-void   *ecalloc __P((size_t nmemb, size_t size));
+void   *emalloc(size_t);
+char   *estrdup(const char *);
+void   *erealloc(void *, size_t);
+void   *ecalloc(size_t, size_t);
diff -r b914136700b4 -r f35cc4ae1a2e sbin/rcorder/hash.c
--- a/sbin/rcorder/hash.c       Sun Jun 30 13:31:15 2002 +0000
+++ b/sbin/rcorder/hash.c       Sun Jun 30 14:17:44 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.1 1999/11/23 05:28:20 mrg Exp $     */
+/*     $NetBSD: hash.c,v 1.2 2002/06/30 14:17:44 lukem Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: hash.c,v 1.1 1999/11/23 05:28:20 mrg Exp $";
+static char rcsid[] = "$NetBSD: hash.c,v 1.2 2002/06/30 14:17:44 lukem Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)hash.c     8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: hash.c,v 1.1 1999/11/23 05:28:20 mrg Exp $");
+__RCSID("$NetBSD: hash.c,v 1.2 2002/06/30 14:17:44 lukem Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -64,10 +64,6 @@
  *     table.  Hash tables grow automatically as the amount of
  *     information increases.
  */
-#include "sprite.h"
-#ifndef ORDER
-#include "make.h"
-#endif /* ORDER */
 #include "hash.h"
 #include "ealloc.h"
 
@@ -76,7 +72,7 @@
  * defined:
  */
 
-static void RebuildTable __P((Hash_Table *));
+static void RebuildTable(Hash_Table *);
 
 /*
  * The following defines the ratio of # entries to # buckets
@@ -92,6 +88,13 @@
  *
  *     This routine just sets up the hash table.
  *
+ * Input:
+ *     t               Structure to use to hold table.
+ *     numBuckets      How many buckets to create for starters.  This number
+ *                     is rounded up to a power of two.  If <= 0, a reasonable
+ *                     default is chosen. The table will grow in size later
+ *                     as needed.
+ *
  * Results:
  *     None.
  *
@@ -102,16 +105,10 @@
  */
 
 void
-Hash_InitTable(t, numBuckets)
-       register Hash_Table *t; /* Structure to use to hold table. */
-       int numBuckets;         /* How many buckets to create for starters.
-                                * This number is rounded up to a power of
-                                * two.   If <= 0, a reasonable default is
-                                * chosen. The table will grow in size later
-                                * as needed. */
+Hash_InitTable(Hash_Table *t, int numBuckets)
 {
-       register int i;
-       register struct Hash_Entry **hp;
+       int i;
+       struct Hash_Entry **hp;
 
        /*
         * Round up the size to a power of two.
@@ -149,12 +146,12 @@
  */
 
 void
-Hash_DeleteTable(t)
-       Hash_Table *t;
+Hash_DeleteTable(Hash_Table *t)
 {
-       register struct Hash_Entry **hp, *h, *nexth = NULL;
-       register int i;
+       struct Hash_Entry **hp, *h, *nexth;
+       int i;
 
+       nexth = NULL;
        for (hp = t->bucketPtr, i = t->size; --i >= 0;) {
                for (h = *hp++; h != NULL; h = nexth) {
                        nexth = h->next;
@@ -177,6 +174,10 @@
  *
  *     Searches a hash table for an entry corresponding to key.
  *
+ * Input:
+ *     t       Hash table to search.
+ *     key     A hash key.
+ *
  * Results:
  *     The return value is a pointer to the entry for key,
  *     if key was present in the table.  If key was not
@@ -189,13 +190,11 @@
  */
 
 Hash_Entry *
-Hash_FindEntry(t, key)
-       Hash_Table *t;          /* Hash table to search. */
-       char *key;              /* A hash key. */
+Hash_FindEntry(Hash_Table *t, char *key)
 {
-       register Hash_Entry *e;
-       register unsigned h;
-       register char *p;
+       Hash_Entry *e;
+       unsigned h;
+       char *p;
 
        for (h = 0, p = key; *p;)
                h = (h << 5) - h + *p++;
@@ -214,6 +213,11 @@
  *     Searches a hash table for an entry corresponding to
  *     key.  If no entry is found, then one is created.
  *
+ * Input:
+ *     t       Hash table to search.
+ *     key     A hash key.
+ *     newPtr  Filled in with 1 if new entry created, 0 otherwise.
+ *
  * Results:
  *     The return value is a pointer to the entry.  If *newPtr
  *     isn't NULL, then *newPtr is filled in with TRUE if a
@@ -226,15 +230,11 @@
  */
 
 Hash_Entry *
-Hash_CreateEntry(t, key, newPtr)
-       register Hash_Table *t; /* Hash table to search. */
-       char *key;              /* A hash key. */
-       Boolean *newPtr;        /* Filled in with TRUE if new entry created,
-                                * FALSE otherwise. */
+Hash_CreateEntry(Hash_Table *t, char *key, int *newPtr)
 {
-       register Hash_Entry *e;
-       register unsigned h;
-       register char *p;
+       Hash_Entry *e;
+       unsigned h;
+       char *p;
        int keylen;
        struct Hash_Entry **hp;
 
@@ -249,7 +249,7 @@
        for (e = t->bucketPtr[h & t->mask]; e != NULL; e = e->next) {
                if (e->namehash == h && strcmp(e->name, p) == 0) {
                        if (newPtr != NULL)
-                               *newPtr = FALSE;
+                               *newPtr = 0;
                        return (e);
                }
        }
@@ -271,7 +271,7 @@
        t->numEntries++;
 
        if (newPtr != NULL)
-               *newPtr = TRUE;
+               *newPtr = 1;
        return (e);
 }
 
@@ -293,11 +293,9 @@
  */
 
 void



Home | Main Index | Thread Index | Old Index