--- gcc/objc/hash.h 2018/04/24 18:03:32 1.1 +++ gcc/objc/hash.h 2018/04/24 18:26:56 1.1.1.5 @@ -1,5 +1,5 @@ /* Hash tables for Objective C method dispatch. - Copyright (C) 1992 Free Software Foundation, Inc. + Copyright (C) 1993, 1995 Free Software Foundation, Inc. This file is part of GNU CC. @@ -15,7 +15,8 @@ GNU General Public License for more deta You should have received a copy of the GNU General Public License along with GNU CC; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ +the Free Software Foundation, 59 Temple Place - Suite 330, +Boston, MA 02111-1307, USA. */ /* As a special exception, if you link this library with files compiled with GCC to produce an executable, this does not cause @@ -27,8 +28,7 @@ the Free Software Foundation, 675 Mass A #ifndef __hash_INCLUDE_GNU #define __hash_INCLUDE_GNU -#include "mutex.h" - +#include /* * This data structure is used to hold items @@ -63,7 +63,7 @@ typedef unsigned int (*hash_func_type)(v /* * This data type is the function that compares two hash keys and returns an * integer greater than, equal to, or less than 0, according as the first - * parameter is lexico-graphically greater than, equal to, or less than the + * parameter is lexicographically greater than, equal to, or less than the * second. */ @@ -114,7 +114,7 @@ cache_ptr hash_new (unsigned int size, void hash_delete (cache_ptr cache); /* Add the key/value pair to the hash table. If the - hash table reaches a level of fullnes then it will be resized. + hash table reaches a level of fullness then it will be resized. assert if the key is already in the hash. */ @@ -145,7 +145,7 @@ void *hash_value_for_key (cache_ptr cach Useful hashing functions. - Declared inline for your pleaseure. + Declared inline for your pleasure. ************************************************/ @@ -153,10 +153,10 @@ void *hash_value_for_key (cache_ptr cach manipulation of the key pointer. (Use the lowest bits except for those likely to be 0 due to alignment.) */ -static inline unsigned int +static inline unsigned int hash_ptr (cache_ptr cache, const void *key) { - return ((unsigned int)key / sizeof (void *)) & cache->mask; + return ((size_t)key / sizeof (void *)) & cache->mask; } @@ -190,7 +190,12 @@ compare_ptrs (const void *k1, const void static inline int compare_strings (const void *k1, const void *k2) { - return !strcmp (k1, k2); + if (k1 == k2) + return 1; + else if (k1 == 0 || k2 == 0) + return 0; + else + return !strcmp (k1, k2); }