eina_clist.h | eina_clist.h | |||
---|---|---|---|---|
skipping to change at line 423 | skipping to change at line 423 | |||
/** | /** | |||
* @def EINA_CLIST_ENTRY | * @def EINA_CLIST_ENTRY | |||
* @brief Get pointer to object containing list element. | * @brief Get pointer to object containing list element. | |||
* @param elem The element to be used. | * @param elem The element to be used. | |||
* @param type The type of the element. | * @param type The type of the element. | |||
* @param field The field of the element. | * @param field The field of the element. | |||
*/ | */ | |||
#undef EINA_CLIST_ENTRY | #undef EINA_CLIST_ENTRY | |||
#define EINA_CLIST_ENTRY(elem, type, field) \ | #define EINA_CLIST_ENTRY(elem, type, field) \ | |||
((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) | ((type *)((char *)(elem) - (uintptr_t)(&((type *)0)->field))) | |||
#include "eina_inline_clist.x" | #include "eina_inline_clist.x" | |||
/** | /** | |||
* @} | * @} | |||
*/ | */ | |||
/** | /** | |||
* @} | * @} | |||
*/ | */ | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
eina_hash.h | eina_hash.h | |||
---|---|---|---|---|
skipping to change at line 229 | skipping to change at line 229 | |||
* few keys are being added, this is not a problem, it will still have not many | * few keys are being added, this is not a problem, it will still have not many | |||
* collisions and be faster to calculate the hash than in a hash created wi th | * collisions and be faster to calculate the hash than in a hash created wi th | |||
* @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new. | * @ref eina_hash_string_small_new and @ref eina_hash_string_superfast_new. | |||
* | * | |||
* A simple comparison between them would be: | * A simple comparison between them would be: | |||
* | * | |||
* @li @c djb2 - faster hash function - 256 buckets (higher memory consumpt ion) | * @li @c djb2 - faster hash function - 256 buckets (higher memory consumpt ion) | |||
* @li @c string_small - slower hash function but less collisions - 32 buck ets | * @li @c string_small - slower hash function but less collisions - 32 buck ets | |||
* (lower memory consumption) | * (lower memory consumption) | |||
* @li @c string_superfast - slower hash function but less collisions - 256 buckets | * @li @c string_superfast - slower hash function but less collisions - 256 buckets | |||
* (higher memory consumption) | * (higher memory consumption) - not randomized, avoid it on public remote interface. | |||
* | * | |||
* Basically for a very small number of keys (10 or less), @c djb2 should b e | * Basically for a very small number of keys (10 or less), @c djb2 should b e | |||
* used, or @c string_small if you have a restriction on memory usage. And for a | * used, or @c string_small if you have a restriction on memory usage. And for a | |||
* higher number of keys, @c string_superfast should be always preferred. | * higher number of keys, @c string_superfast should be preferred if not us | |||
ed on a | ||||
* public remote interface. | ||||
* | * | |||
* If just stringshared keys are being added, use @ref | * If just stringshared keys are being added, use @ref | |||
* eina_hash_stringshared_new. If a lot of keys will be added to the hash t able | * eina_hash_stringshared_new. If a lot of keys will be added to the hash t able | |||
* (e.g. more than 1000), then it's better to increase the buckets_power_si ze. | * (e.g. more than 1000), then it's better to increase the buckets_power_si ze. | |||
* See @ref eina_hash_new for more details. | * See @ref eina_hash_new for more details. | |||
* | * | |||
* When adding a new key to a hash table, use @ref eina_hash_add or @ref | * When adding a new key to a hash table, use @ref eina_hash_add or @ref | |||
* eina_hash_direct_add (the latter if this key is already stored elsewhere ). If | * eina_hash_direct_add (the latter if this key is already stored elsewhere ). If | |||
* the key may be already inside the hash table, instead of checking with | * the key may be already inside the hash table, instead of checking with | |||
* @ref eina_hash_find and then doing @ref eina_hash_add, one can use just @ref | * @ref eina_hash_find and then doing @ref eina_hash_add, one can use just @ref | |||
skipping to change at line 397 | skipping to change at line 398 | |||
* @param data_free_cb The function called on each value when the hash tabl e | * @param data_free_cb The function called on each value when the hash tabl e | |||
* is freed, or when an item is deleted from it. @c NULL can be passed as | * is freed, or when an item is deleted from it. @c NULL can be passed as | |||
* callback. | * callback. | |||
* @return The new hash table. | * @return The new hash table. | |||
* | * | |||
* This function creates a new hash table using the superfast algorithm | * This function creates a new hash table using the superfast algorithm | |||
* for table management and strcmp() to compare the keys. Values can | * for table management and strcmp() to compare the keys. Values can | |||
* then be looked up with pointers other than the original key pointer | * then be looked up with pointers other than the original key pointer | |||
* that was used to add values. On failure, this function returns | * that was used to add values. On failure, this function returns | |||
* @c NULL. | * @c NULL. | |||
* | ||||
* NOTE: don't use this kind of hash when their is a possibility to remotel | ||||
y | ||||
* request and push data in it. This hash is subject to denial of service. | ||||
*/ | */ | |||
EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb); | EAPI Eina_Hash *eina_hash_string_superfast_new(Eina_Free_Cb data_free_cb); | |||
/** | /** | |||
* @brief Create a new hash table for use with strings with small bucket si ze. | * @brief Create a new hash table for use with strings with small bucket si ze. | |||
* | * | |||
* @param data_free_cb The function called on each value when the hash tab le | * @param data_free_cb The function called on each value when the hash tab le | |||
* is freed, or when an item is deleted from it. @c NULL can be passed as | * is freed, or when an item is deleted from it. @c NULL can be passed as | |||
* callback. | * callback. | |||
* @return The new hash table. | * @return The new hash table. | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 8 lines changed or added | |||
eina_inline_hash.x | eina_inline_hash.x | |||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
* Lesser General Public License for more details. | * Lesser General Public License for more details. | |||
* | * | |||
* You should have received a copy of the GNU Lesser General Public | * You should have received a copy of the GNU Lesser General Public | |||
* License along with this library; | * License along with this library; | |||
* if not, see <http://www.gnu.org/licenses/>. | * if not, see <http://www.gnu.org/licenses/>. | |||
*/ | */ | |||
#ifndef EINA_INLINE_HASH_X_ | #ifndef EINA_INLINE_HASH_X_ | |||
#define EINA_INLINE_HASH_X_ | #define EINA_INLINE_HASH_X_ | |||
EAPI extern unsigned int eina_seed; | ||||
/* | /* | |||
djb2 hash algorithm was first reported by dan bernstein, and was the old | djb2 hash algorithm was first reported by dan bernstein, and was the old | |||
default hash function for evas. | default hash function for evas. | |||
*/ | */ | |||
static inline int | static inline int | |||
eina_hash_djb2(const char *key, int len) | eina_hash_djb2(const char *key, int len) | |||
{ | { | |||
unsigned int hash_num = 5381; | unsigned int hash_num = 5381 ^ eina_seed; | |||
const unsigned char *ptr; | const unsigned char *ptr; | |||
if (!key) return 0; | if (!key) return 0; | |||
for (ptr = (unsigned char *)key; len; ptr++, len--) | for (ptr = (unsigned char *)key; len; ptr++, len--) | |||
hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ | hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ | |||
return (int)hash_num; | return (int)hash_num; | |||
} | } | |||
static inline int | static inline int | |||
eina_hash_djb2_len(const char *key, int *plen) | eina_hash_djb2_len(const char *key, int *plen) | |||
{ | { | |||
unsigned int hash_num = 5381; | unsigned int hash_num = 5381 ^ eina_seed; | |||
int len = 0; | int len = 0; | |||
const unsigned char *ptr; | const unsigned char *ptr; | |||
if (!key) return 0; | if (!key) return 0; | |||
for (ptr = (unsigned char *)key; *ptr; ptr++, len++) | for (ptr = (unsigned char *)key; *ptr; ptr++, len++) | |||
hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ | hash_num = ((hash_num << 5) + hash_num) ^ *ptr; /* hash * 33 ^ c */ | |||
*plen = len + 1; | *plen = len + 1; | |||
skipping to change at line 67 | skipping to change at line 69 | |||
eina_hash_int32(const unsigned int *pkey, int len) | eina_hash_int32(const unsigned int *pkey, int len) | |||
{ | { | |||
unsigned int key = *pkey; | unsigned int key = *pkey; | |||
(void) len; | (void) len; | |||
key = ~key + (key << 15); | key = ~key + (key << 15); | |||
key ^= key >> 12; | key ^= key >> 12; | |||
key += key << 2; | key += key << 2; | |||
key ^= key >> 4; | key ^= key >> 4; | |||
key *= 2057; | key *= 2057 ^ eina_seed; | |||
key ^= key >> 16; | key ^= key >> 16; | |||
return key; | return key; | |||
} | } | |||
static inline int | static inline int | |||
eina_hash_int64(const unsigned long int *pkey, int len) | eina_hash_int64(const unsigned long int *pkey, int len) | |||
{ | { | |||
unsigned long int key = *pkey; | unsigned long int key = *pkey; | |||
(void) len; | (void) len; | |||
key = ~key + (key << 18); | key = ~key + (key << 18); | |||
key ^= key >> 31; | key ^= key >> 31; | |||
key *= 21; | key *= 21 ^ eina_seed; | |||
key ^= key >> 11; | key ^= key >> 11; | |||
key += key << 6; | key += key << 6; | |||
key ^= key >> 22; | key ^= key >> 22; | |||
return (int) key; | return (int) key; | |||
} | } | |||
static inline unsigned int _rotl32(unsigned int x, char r) | static inline unsigned int _rotl32(unsigned int x, char r) | |||
{ | { | |||
return (x << r) | (x >> (32 - r)); | return (x << r) | (x >> (32 - r)); | |||
} | } | |||
skipping to change at line 110 | skipping to change at line 112 | |||
return h; | return h; | |||
} | } | |||
static inline int | static inline int | |||
eina_hash_murmur3(const char *key, int len) | eina_hash_murmur3(const char *key, int len) | |||
{ | { | |||
const unsigned char * data = (const unsigned char*)key; | const unsigned char * data = (const unsigned char*)key; | |||
const int nblocks = len / 4; | const int nblocks = len / 4; | |||
unsigned int h1 = 0, k1; | unsigned int h1 = 0, k1; | |||
unsigned int c1 = 0xcc9e2d51; | unsigned int c1 = 0xcc9e2d51 ^ eina_seed; | |||
unsigned int c2 = 0x1b873593; | unsigned int c2 = 0x1b873593 ^ eina_seed; | |||
const unsigned int * blocks = (const unsigned int *)(data + nblocks*4); | const unsigned int * blocks = (const unsigned int *)(data + nblocks*4); | |||
int i; | int i; | |||
const unsigned char *tail; | const unsigned char *tail; | |||
for(i = -nblocks; i; i++) | for(i = -nblocks; i; i++) | |||
{ | { | |||
k1 = blocks[i]; | k1 = blocks[i]; | |||
k1 *= c1; | k1 *= c1; | |||
k1 = _rotl32(k1, 15); | k1 = _rotl32(k1, 15); | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 8 lines changed or added | |||
eina_inline_value.x | eina_inline_value.x | |||
---|---|---|---|---|
skipping to change at line 582 | skipping to change at line 582 | |||
return EINA_TRUE; | return EINA_TRUE; | |||
} | } | |||
static inline unsigned int | static inline unsigned int | |||
eina_value_array_count(const Eina_Value *value) | eina_value_array_count(const Eina_Value *value) | |||
{ | { | |||
Eina_Value_Array desc; | Eina_Value_Array desc; | |||
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | |||
if (!eina_value_pget(value, &desc)) | if (!eina_value_pget(value, &desc)) | |||
return 0; | return 0; | |||
return eina_inarray_count(desc.array); | return desc.array ? eina_inarray_count(desc.array) : 0; | |||
} | } | |||
static inline Eina_Bool | static inline Eina_Bool | |||
eina_value_array_remove(Eina_Value *value, unsigned int position) | eina_value_array_remove(Eina_Value *value, unsigned int position) | |||
{ | { | |||
Eina_Value_Array desc; | Eina_Value_Array desc; | |||
void *mem; | void *mem; | |||
EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | |||
if (!eina_value_pget(value, &desc)) | if (!eina_value_pget(value, &desc)) | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||