1 /***************************************************************************/ 2 /* */ 3 /* fthash.c */ 4 /* */ 5 /* Hashing functions (body). */ 6 /* */ 7 /***************************************************************************/ 8 9 /* 10 * Copyright 2000 Computing Research Labs, New Mexico State University 11 * Copyright 2001-2015 12 * Francesco Zappa Nardelli 13 * 14 * Permission is hereby granted, free of charge, to any person obtaining a 15 * copy of this software and associated documentation files (the "Software"), 16 * to deal in the Software without restriction, including without limitation 17 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 * and/or sell copies of the Software, and to permit persons to whom the 19 * Software is furnished to do so, subject to the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be included in 22 * all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 28 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 29 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 30 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 */ 32 33 /*************************************************************************/ 34 /* */ 35 /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */ 36 /* */ 37 /* taken from Mark Leisher's xmbdfed package */ 38 /* */ 39 /*************************************************************************/ 40 41 42 #include <ft2build.h> 43 #include FT_INTERNAL_HASH_H 44 #include FT_INTERNAL_MEMORY_H 45 46 47 #define INITIAL_HT_SIZE 241 48 49 50 static FT_ULong 51 hash_str_lookup( FT_Hashkey* key ) 52 { 53 const char* kp = key->str; 54 FT_ULong res = 0; 55 56 57 /* Mocklisp hash function. */ 58 while ( *kp ) 59 res = ( res << 5 ) - res + (FT_ULong)*kp++; | 1 /**************************************************************************** 2 * 3 * fthash.c 4 * 5 * Hashing functions (body). 6 * 7 */ 8 9 /* 10 * Copyright 2000 Computing Research Labs, New Mexico State University 11 * Copyright 2001-2015 12 * Francesco Zappa Nardelli 13 * 14 * Permission is hereby granted, free of charge, to any person obtaining a 15 * copy of this software and associated documentation files (the "Software"), 16 * to deal in the Software without restriction, including without limitation 17 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 * and/or sell copies of the Software, and to permit persons to whom the 19 * Software is furnished to do so, subject to the following conditions: 20 * 21 * The above copyright notice and this permission notice shall be included in 22 * all copies or substantial portions of the Software. 23 * 24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY 28 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT 29 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 30 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 */ 32 33 /************************************************************************** 34 * 35 * This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 36 * 37 * taken from Mark Leisher's xmbdfed package 38 * 39 */ 40 41 42 #include <ft2build.h> 43 #include FT_INTERNAL_HASH_H 44 #include FT_INTERNAL_MEMORY_H 45 46 47 #define INITIAL_HT_SIZE 241 48 49 50 static FT_ULong 51 hash_str_lookup( FT_Hashkey* key ) 52 { 53 const char* kp = key->str; 54 FT_ULong res = 0; 55 56 57 /* Mocklisp hash function. */ 58 while ( *kp ) 59 res = ( res << 5 ) - res + (FT_ULong)*kp++; |