FILE *_eet_memfile_write_open(void **data, size_t *size);
void _eet_memfile_write_close(FILE *f);
void _eet_memfile_shutdown(void);
+int _eet_hash_gen(const char *key, int hash_size);
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
-/* caluclate hash table entry valu with bitmask size of hash_size */
-static int
-eet_hash_gen(const char *key, int hash_size)
-{
- int hash_num = 0;
- int value, i;
- unsigned char *ptr;
-
- const int masks[9] =
- {
- 0x00,
- 0x01,
- 0x03,
- 0x07,
- 0x0f,
- 0x1f,
- 0x3f,
- 0x7f,
- 0xff
- };
-
- /* no string - index 0 */
- if (!key) return 0;
-
- /* calc hash num */
- for (i = 0, ptr = (unsigned char *)key, value = (int)(*ptr);
- value;
- ptr++, i++, value = (int)(*ptr))
- hash_num ^= (value | (value << 8)) >> (i & 0x7);
-
- /* mask it */
- hash_num &= masks[hash_size];
- /* return it */
- return hash_num;
-}
-
#endif
eet_data.c \
eet_image.c \
eet_memfile.c \
+eet_utils.c \
Eet_private.h
libeet_la_LIBADD = -lz -ljpeg @fnmatch_libs@ @winsock_libs@
int hash;
ede = &(edd->elements.set[i]);
- hash = eet_hash_gen((char *) ede->name, 6);
+ hash = _eet_hash_gen((char *) ede->name, 6);
if (!edd->elements.hash.buckets[hash].element)
edd->elements.hash.buckets[hash].element = ede;
else
int hash;
Eet_Data_Descriptor_Hash *bucket;
- hash = eet_hash_gen(name, 6);
+ hash = _eet_hash_gen(name, 6);
if (!edd->elements.hash.buckets[hash].element) return NULL;
if (!strcmp(edd->elements.hash.buckets[hash].element->name, name))
return edd->elements.hash.buckets[hash].element;
efn->name = (char*)((uint8_t*)(p + HEADER_SIZE));
/* get hash bucket it should go in */
- hash = eet_hash_gen(efn->name, ef->header->directory->size);
+ hash = _eet_hash_gen(efn->name, ef->header->directory->size);
efn->next = ef->header->directory->nodes[hash];
ef->header->directory->nodes[hash] = efn;
}
/* figure hash bucket */
- hash = eet_hash_gen(name, ef->header->directory->size);
+ hash = _eet_hash_gen(name, ef->header->directory->size);
data_size = compress ? 12 + ((size * 101) / 100) : size;
return 0;
/* figure hash bucket */
- hash = eet_hash_gen(name, ef->header->directory->size);
+ hash = _eet_hash_gen(name, ef->header->directory->size);
/* Does this node already exist? */
for (pefn = NULL, efn = ef->header->directory->nodes[hash];
int hash;
/* get hash bucket this should be in */
- hash = eet_hash_gen(name, ef->header->directory->size);
+ hash = _eet_hash_gen(name, ef->header->directory->size);
for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
{
--- /dev/null
+int
+_eet_hash_gen(const char *key, int hash_size)
+{
+ int hash_num = 0;
+ int value, i;
+ unsigned char *ptr;
+
+ const int masks[9] =
+ {
+ 0x00,
+ 0x01,
+ 0x03,
+ 0x07,
+ 0x0f,
+ 0x1f,
+ 0x3f,
+ 0x7f,
+ 0xff
+ };
+
+ /* no string - index 0 */
+ if (!key) return 0;
+
+ /* calc hash num */
+ for (i = 0, ptr = (unsigned char *)key, value = (int)(*ptr);
+ value;
+ ptr++, i++, value = (int)(*ptr))
+ hash_num ^= (value | (value << 8)) >> (i & 0x7);
+
+ /* mask it */
+ hash_num &= masks[hash_size];
+ /* return it */
+ return hash_num;
+}
+