3 Copyright (C) 2001 Christopher Rosendahl <smugg@fatelabs.com>
4 Nathan Ingersoll <ningerso@d.umn.edu>
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to
8 deal in the Software without restriction, including without limitation the
9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 sell copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies of the Software and its documentation and acknowledgment shall be
15 given in the documentation and software packages that this Software was
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "Ecore_Data.h"
29 #include "ecore_private.h"
31 EAPI const unsigned int ecore_prime_table[] =
33 17, 31, 61, 127, 257, 509, 1021,
34 2053, 4093, 8191, 16381, 32771, 65537, 131071, 262147, 524287, 1048573,
35 2097143, 4194301, 8388617, 16777213
39 ecore_print_warning(const char *function, const char *sparam)
41 fprintf(stderr, "***** Developer Warning ***** :\n"
42 "\tThis program is calling:\n\n"
44 "\tWith the parameter:\n\n"
46 "\tbeing NULL. Please fix your program.\n", function, sparam);
48 if (getenv("ECORE_ERROR_ABORT")) abort();
52 * Just casts the key to an unsigned int
53 * @param key The key to return compute a hash value
54 * @return The key cast to an unsigned int.
57 ecore_direct_hash(const void *key)
60 unsigned long int val = (unsigned long int)key;
62 return (unsigned int) ((val >> 32) ^ val);
64 return (unsigned int) key;
69 * Compute the hash value of a string
70 * @param key A pointer to the string to compute a hash value
71 * @return A computed hash value for @a key.
74 ecore_str_hash(const void *key)
78 unsigned int value = 0;
84 mask = (sizeof(unsigned int) * 8) - 1;
86 for (i = 0; k[i] != '\0'; i++)
88 value ^= ((unsigned int) k[i] << ((i * 5) & mask));
95 * Perform a direct comparison of two keys' values
96 * @param key1 The first key to compare
97 * @param key2 The second key to compare
98 * @return A strcmp style value to indicate the larger key
101 ecore_direct_compare(const void *key1, const void *key2)
105 k1 = (unsigned int) key1;
106 k2 = (unsigned int) key2;
118 * Perform a string comparison of two keys values
119 * @param key1 The first key to compare
120 * @param key2 The second key to compare
121 * @return A strcmp style value to indicate the larger key
124 ecore_str_compare(const void *key1, const void *key2)
129 return ecore_direct_compare(key1, key2);
130 else if (key1 == key2)
136 return strcmp(k1, k2);