about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTAtom.c
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation/HTAtom.c')
-rw-r--r--WWW/Library/Implementation/HTAtom.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/WWW/Library/Implementation/HTAtom.c b/WWW/Library/Implementation/HTAtom.c
index d8bf1106..1874671b 100644
--- a/WWW/Library/Implementation/HTAtom.c
+++ b/WWW/Library/Implementation/HTAtom.c
@@ -1,21 +1,21 @@
 /*			Atoms: Names to numbers			HTAtom.c
-**			=======================
-**
-**	Atoms are names which are given representative pointer values
-**	so that they can be stored more efficiently, and comparisons
-**	for equality done more efficiently.
-**
-**	Atoms are kept in a hash table consisting of an array of linked lists.
-**
-** Authors:
-**	TBL	Tim Berners-Lee, WorldWideWeb project, CERN
-**	(c) Copyright CERN 1991 - See Copyright.html
-**
-*/
+ *			=======================
+ *
+ *	Atoms are names which are given representative pointer values
+ *	so that they can be stored more efficiently, and comparisons
+ *	for equality done more efficiently.
+ *
+ *	Atoms are kept in a hash table consisting of an array of linked lists.
+ *
+ * Authors:
+ *	TBL	Tim Berners-Lee, WorldWideWeb project, CERN
+ *	(c) Copyright CERN 1991 - See Copyright.html
+ *
+ */
 
 #include <HTUtils.h>
 
-#define HASH_SIZE	101		/* Tunable */
+#define HASH_SIZE	101	/* Tunable */
 #include <HTAtom.h>
 
 #include <HTList.h>
@@ -23,14 +23,14 @@
 #include <LYexit.h>
 #include <LYLeaks.h>
 
-static HTAtom * hash_table[HASH_SIZE];
+static HTAtom *hash_table[HASH_SIZE];
 static BOOL initialised = NO;
 
 /*
  *	To free off all atoms.
  */
 #ifdef LY_FIND_LEAKS
-static void free_atoms (void);
+static void free_atoms(void);
 #endif
 
 /*
@@ -38,19 +38,20 @@ static void free_atoms (void);
  */
 #define HASH_FUNCTION(cp_hash) ((strlen(cp_hash) * UCH(*cp_hash)) % HASH_SIZE)
 
-HTAtom * HTAtom_for (const char * string)
+HTAtom *HTAtom_for(const char *string)
 {
     int hash;
-    HTAtom * a;
+    HTAtom *a;
 
-    /*		First time around, clear hash table
-    */
+    /* First time around, clear hash table
+     */
     /*
-     *	Memory leak fixed.
-     *  05-29-94 Lynx 2-3-1 Garrett Arch Blythe
+     * Memory leak fixed.
+     * 05-29-94 Lynx 2-3-1 Garrett Arch Blythe
      */
     if (!initialised) {
 	int i;
+
 	for (i = 0; i < HASH_SIZE; i++)
 	    hash_table[i] = (HTAtom *) 0;
 	initialised = YES;
@@ -59,29 +60,29 @@ HTAtom * HTAtom_for (const char * string)
 #endif
     }
 
-    /*		Generate hash function
-    */
+    /*          Generate hash function
+     */
     hash = HASH_FUNCTION(string);
 
-    /*		Search for the string in the list
-    */
+    /*          Search for the string in the list
+     */
     for (a = hash_table[hash]; a; a = a->next) {
 	if (0 == strcasecomp(a->name, string)) {
 	    /* CTRACE((tfp, "HTAtom: Old atom %p for `%s'\n", a, string)); */
-	    return a;				/* Found: return it */
+	    return a;		/* Found: return it */
 	}
     }
 
-    /*		Generate a new entry
-    */
-    a = (HTAtom *)malloc(sizeof(*a));
+    /*          Generate a new entry
+     */
+    a = (HTAtom *) malloc(sizeof(*a));
     if (a == NULL)
 	outofmem(__FILE__, "HTAtom_for");
-    a->name = (char *)malloc(strlen(string)+1);
+    a->name = (char *) malloc(strlen(string) + 1);
     if (a->name == NULL)
 	outofmem(__FILE__, "HTAtom_for");
     strcpy(a->name, string);
-    a->next = hash_table[hash];		/* Put onto the head of list */
+    a->next = hash_table[hash];	/* Put onto the head of list */
     hash_table[hash] = a;
 #ifdef NOT_DEFINED
     CTRACE((tfp, "HTAtom: New atom %p for `%s'\n", a, string));
@@ -99,32 +100,33 @@ HTAtom * HTAtom_for (const char * string)
  *	Revision History:
  *		05-29-94	created Lynx 2-3-1 Garrett Arch Blythe
  */
-static void free_atoms (void)
+static void free_atoms(void)
 {
-	auto int i_counter;
-	HTAtom *HTAp_freeme;
+    auto int i_counter;
+    HTAtom *HTAp_freeme;
+
+    /*
+     * Loop through all lists of atoms.
+     */
+    for (i_counter = 0; i_counter < HASH_SIZE; i_counter++) {
 	/*
-	 *	Loop through all lists of atoms.
+	 * Loop through the list.
 	 */
-	for (i_counter = 0; i_counter < HASH_SIZE; i_counter++)	{
-		/*
-		 *	Loop through the list.
-		 */
-		while (hash_table[i_counter] != NULL)	{
-			/*
-			 *	Free off atoms and any members.
-			 */
-			HTAp_freeme = hash_table[i_counter];
-			hash_table[i_counter] = HTAp_freeme->next;
-			FREE(HTAp_freeme->name);
-			FREE(HTAp_freeme);
-		}
+	while (hash_table[i_counter] != NULL) {
+	    /*
+	     * Free off atoms and any members.
+	     */
+	    HTAp_freeme = hash_table[i_counter];
+	    hash_table[i_counter] = HTAp_freeme->next;
+	    FREE(HTAp_freeme->name);
+	    FREE(HTAp_freeme);
 	}
+    }
 }
 #endif /* LY_FIND_LEAKS */
 
-static BOOL mime_match (const char * name,
-			      const char * templ)
+static BOOL mime_match(const char *name,
+		       const char *templ)
 {
     if (name && templ) {
 	static char *n1 = NULL;
@@ -132,14 +134,14 @@ static BOOL mime_match (const char * name,
 	char *n2;
 	char *t2;
 
-	StrAllocCopy(n1, name);		/* These also free the ones	*/
-	StrAllocCopy(t1, templ);	/* from previous call.		*/
+	StrAllocCopy(n1, name);	/* These also free the ones */
+	StrAllocCopy(t1, templ);	/* from previous call.  */
 
-	if (!(n2 = strchr(n1, '/'))  ||  !(t2 = strchr(t1, '/')))
+	if (!(n2 = strchr(n1, '/')) || !(t2 = strchr(t1, '/')))
 	    return NO;
 
-	*(n2++) = (char)0;
-	*(t2++) = (char)0;
+	*(n2++) = (char) 0;
+	*(t2++) = (char) 0;
 
 	if ((0 == strcmp(t1, "*") || 0 == strcmp(t1, n1)) &&
 	    (0 == strcmp(t2, "*") || 0 == strcmp(t2, n2)))
@@ -148,8 +150,7 @@ static BOOL mime_match (const char * name,
     return NO;
 }
 
-
-HTList *HTAtom_templateMatches (const char * templ)
+HTList *HTAtom_templateMatches(const char *templ)
 {
     HTList *matches = HTList_new();
 
@@ -158,12 +159,11 @@ HTList *HTAtom_templateMatches (const char * templ)
 	HTAtom *cur;
 
 	for (i = 0; i < HASH_SIZE; i++) {
-	    for (cur = hash_table[i];  cur;  cur = cur->next) {
+	    for (cur = hash_table[i]; cur; cur = cur->next) {
 		if (mime_match(cur->name, templ))
-		    HTList_addObject(matches, (void*)cur);
+		    HTList_addObject(matches, (void *) cur);
 	    }
 	}
     }
     return matches;
 }
-