BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / make / hash.c
index 7ee9b71..7c24f7e 100644 (file)
@@ -1,18 +1,39 @@
+/*
+ * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
+ * Copyright (c) 1988, 1989 by Adam de Boor
+ * Copyright (c) 1989 by Berkeley Softworks
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Adam de Boor.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)hash.c     5.4 (Berkeley) 6/1/90";
+#endif /* not lint */
+
 /* hash.c --
  *
  *     This module contains routines to manipulate a hash table.
  *     See hash.h for a definition of the structure of the hash
  *     table.  Hash tables grow automatically as the amount of
  *     information increases.
 /* hash.c --
  *
  *     This module contains routines to manipulate a hash table.
  *     See hash.h for a definition of the structure of the hash
  *     table.  Hash tables grow automatically as the amount of
  *     information increases.
- *
- * Copyright (C) 1983 Regents of the University of California
- * All rights reserved.
  */
 
  */
 
-#ifndef lint
-static char rcsid[] = "$Id: hash.c,v 2.1 89/06/13 17:24:54 adam Exp $ SPRITE (Berkeley)";
-#endif  not lint
-
 #include "sprite.h"
 #include "hash.h"
 #include "list.h"
 #include "sprite.h"
 #include "hash.h"
 #include "list.h"
@@ -92,7 +113,7 @@ Hash_InitTable(tablePtr, numBuckets, keyType)
        tablePtr->downShift--;
     }
 
        tablePtr->downShift--;
     }
 
-    tablePtr->bucketPtr = (List_Links *) malloc(sizeof(List_Links)
+    tablePtr->bucketPtr = (List_Links *) emalloc(sizeof(List_Links)
            * tablePtr->size);
     for (i=0, bucketPtr = tablePtr->bucketPtr; i < tablePtr->size;
            i++, bucketPtr++) {
            * tablePtr->size);
     for (i=0, bucketPtr = tablePtr->bucketPtr; i < tablePtr->size;
            i++, bucketPtr++) {
@@ -236,17 +257,17 @@ Hash_CreateEntry(tablePtr, key, newPtr)
 
     switch (tablePtr->keyType) {
        case HASH_STRING_KEYS:
 
     switch (tablePtr->keyType) {
        case HASH_STRING_KEYS:
-           hashEntryPtr = (Hash_Entry *) malloc(sizeof(Hash_Entry) + 
+           hashEntryPtr = (Hash_Entry *) emalloc(sizeof(Hash_Entry) + 
                    strlen((char *) keyPtr) - 3);
            strcpy(hashEntryPtr->key.name, (char *) keyPtr);
            break;
        case HASH_ONE_WORD_KEYS:
                    strlen((char *) keyPtr) - 3);
            strcpy(hashEntryPtr->key.name, (char *) keyPtr);
            break;
        case HASH_ONE_WORD_KEYS:
-           hashEntryPtr = (Hash_Entry *) malloc(sizeof(Hash_Entry));
+           hashEntryPtr = (Hash_Entry *) emalloc(sizeof(Hash_Entry));
            hashEntryPtr->key.ptr = (Address) keyPtr;
            break;
        case 2:
            hashEntryPtr = 
            hashEntryPtr->key.ptr = (Address) keyPtr;
            break;
        case 2:
            hashEntryPtr = 
-               (Hash_Entry *) malloc(sizeof(Hash_Entry) + sizeof(int));
+               (Hash_Entry *) emalloc(sizeof(Hash_Entry) + sizeof(int));
            hashKeyPtr = hashEntryPtr->key.words;
            *hashKeyPtr++ = *keyPtr++;
            *hashKeyPtr = *keyPtr;
            hashKeyPtr = hashEntryPtr->key.words;
            *hashKeyPtr++ = *keyPtr++;
            *hashKeyPtr = *keyPtr;
@@ -256,7 +277,7 @@ Hash_CreateEntry(tablePtr, key, newPtr)
 
            n = tablePtr->keyType;
            hashEntryPtr = (Hash_Entry *) 
 
            n = tablePtr->keyType;
            hashEntryPtr = (Hash_Entry *) 
-                   malloc(sizeof(Hash_Entry) + (n - 1) * sizeof(int));
+                   emalloc(sizeof(Hash_Entry) + (n - 1) * sizeof(int));
            hashKeyPtr = hashEntryPtr->key.words;
            do { 
                *hashKeyPtr++ = *keyPtr++; 
            hashKeyPtr = hashEntryPtr->key.words;
            do { 
                *hashKeyPtr++ = *keyPtr++;