return NULL;
memset(new->hash, -1, sizeof (int) * 256);
- eina_spinlock_new(&new->mutex);
+ eina_rwlock_new(&new->rwlock);
return new;
}
if (!ed) return;
- eina_spinlock_free(&ed->mutex);
+ eina_rwlock_free(&ed->rwlock);
for (i = 0; i < ed->count; ++i)
if (ed->all_allocated[i >> 3] & (1 << (i & 0x7)))
hash = _eet_hash_gen(string, 8);
len = strlen(string) + 1;
- eina_spinlock_take(&ed->mutex);
+ eina_rwlock_take_read(&ed->rwlock);
idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx);
((ed->all[idx].str == string) ||
(!strcmp(ed->all[idx].str, string))))
{
- eina_spinlock_release(&ed->mutex);
+ eina_rwlock_release(&ed->rwlock);
return idx;
}
}
+ str = eina_stringshare_add(string);
+ if (!str) goto on_error;
+
+ eina_rwlock_release(&ed->rwlock);
+ eina_rwlock_take_write(&ed->rwlock);
if (ed->total == ed->count)
{
Eet_String *new;
unsigned char *new_allocated;
int total;
- total = ed->total + 8;
+ total = ed->total + 64;
new = realloc(ed->all, total * sizeof(Eet_String));
if (!new) goto on_error;
ed->total = total;
}
- str = eina_stringshare_add(string);
- if (!str) goto on_error;
-
current = ed->all + ed->count;
ed->all_allocated[ed->count >> 3] |= (1 << (ed->count & 0x7));
}
cnt = ed->count++;
- eina_spinlock_release(&ed->mutex);
+ eina_rwlock_release(&ed->rwlock);
return cnt;
on_error:
- eina_spinlock_release(&ed->mutex);
+ eina_rwlock_release(&ed->rwlock);
return -1;
}
if (idx < 0) goto done;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (idx < ed->count)
length = ed->all[idx].len;
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
done:
return length;
if (idx < 0) goto done;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (idx < ed->count)
hash = ed->all_hash[idx];
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
done:
return hash;
if (idx < 0) goto done;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (idx < ed->count)
{
s = ed->all[idx].str;
}
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
done:
return s;
if (idx < 0) goto done;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (!(idx < ed->count)) goto unlock_done;
limit = EINA_TRUE;
unlock_done:
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
done:
return limit;
{
Eet_Convert *result;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
*str = ed->all[idx].str;
eina_hash_add(ed->converts, &idx, result);
done:
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
return result;
}
if (!(convert->type & EET_D_FLOAT))
{
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (!_eet_dictionary_string_get_float_cache(str, ed->all[idx].len,
&convert->f))
{
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
&exponent) == EINA_FALSE)
{
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
return EINA_FALSE;
}
convert->f = ldexpf((float)mantisse, exponent);
}
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
convert->type |= EET_D_FLOAT;
}
if (!(convert->type & EET_D_DOUBLE))
{
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (!_eet_dictionary_string_get_double_cache(str, ed->all[idx].len,
&convert->d))
if (eina_convert_atod(str, ed->all[idx].len, &mantisse,
&exponent) == EINA_FALSE)
{
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
return EINA_FALSE;
}
convert->d = ldexp((double)mantisse, exponent);
}
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
convert->type |= EET_D_DOUBLE;
}
{
Eina_F32p32 fp;
- eina_spinlock_take((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if (!eina_convert_atofp(str, ed->all[idx].len, &fp))
{
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
return EINA_FALSE;
}
- eina_spinlock_release((Eina_Spinlock*) &ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
convert->fp = fp;
convert->type |= EET_D_FIXED_POINT;
if ((!ed) || (!string))
return 0;
- eina_spinlock_take(&ed->mutex);
+ eina_rwlock_take_read((Eina_RWLock *)&ed->rwlock);
if ((ed->start <= string) && (string < ed->end))
res = 1;
}
}
- eina_spinlock_release(&ed->mutex);
+ eina_rwlock_release((Eina_RWLock *)&ed->rwlock);
return res;
}