forked from enlightenment/efl
* eet: fix eet dictionnary ever growing dictionnary.
SVN revision: 51860
This commit is contained in:
parent
3aedfa6956
commit
dd168d1058
|
@ -434,5 +434,9 @@
|
||||||
|
|
||||||
2010-08-27 Cedric BAIL
|
2010-08-27 Cedric BAIL
|
||||||
|
|
||||||
* prevent the build of eet data structure that doesn't match what
|
* Prevent the build of eet data structure that doesn't match what
|
||||||
the application is expecting.
|
the application is expecting.
|
||||||
|
|
||||||
|
2010-09-02 Cedric BAIL
|
||||||
|
|
||||||
|
* Fix bug of ever growing dictionnary and improve strcmp comparison.
|
||||||
|
|
|
@ -46,8 +46,10 @@ eet_dictionary_free(Eet_Dictionary *ed)
|
||||||
static int
|
static int
|
||||||
_eet_dictionary_lookup(Eet_Dictionary *ed,
|
_eet_dictionary_lookup(Eet_Dictionary *ed,
|
||||||
const char *string,
|
const char *string,
|
||||||
|
int len,
|
||||||
int hash)
|
int hash)
|
||||||
{
|
{
|
||||||
|
Eina_Bool found = EINA_FALSE;
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
int current;
|
int current;
|
||||||
|
|
||||||
|
@ -55,19 +57,28 @@ _eet_dictionary_lookup(Eet_Dictionary *ed,
|
||||||
|
|
||||||
while (current != -1)
|
while (current != -1)
|
||||||
{
|
{
|
||||||
if (ed->all[current].str)
|
if (ed->all[current].len == len)
|
||||||
if (strcmp(ed->all[current].str, string) >= 0)
|
{
|
||||||
break;
|
if (ed->all[current].str)
|
||||||
|
if (strcmp(ed->all[current].str, string) == 0)
|
||||||
|
{
|
||||||
|
found = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (ed->all[current].mmap)
|
if (ed->all[current].mmap)
|
||||||
if (strcmp(ed->all[current].mmap, string) >= 0)
|
if (strcmp(ed->all[current].mmap, string) == 0)
|
||||||
break;
|
{
|
||||||
|
found = EINA_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prev = current;
|
prev = current;
|
||||||
current = ed->all[current].next;
|
current = ed->all[current].next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current == -1)
|
if (current == -1 && found)
|
||||||
return prev;
|
return prev;
|
||||||
|
|
||||||
return current;
|
return current;
|
||||||
|
@ -87,19 +98,19 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
hash = _eet_hash_gen(string, 8);
|
hash = _eet_hash_gen(string, 8);
|
||||||
|
len = strlen(string) + 1;
|
||||||
|
|
||||||
idx = _eet_dictionary_lookup(ed, string, hash);
|
idx = _eet_dictionary_lookup(ed, string, len, hash);
|
||||||
|
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
{
|
{
|
||||||
if (ed->all[idx].str)
|
if (ed->all[idx].str)
|
||||||
if (strcmp(ed->all[idx].str, string) == 0)
|
if (strcmp(ed->all[idx].str, string) == 0)
|
||||||
return idx;
|
return idx;
|
||||||
|
|
||||||
if (ed->all[idx].mmap)
|
if (ed->all[idx].mmap)
|
||||||
if (strcmp(ed->all[idx].mmap, string) == 0)
|
if (strcmp(ed->all[idx].mmap, string) == 0)
|
||||||
return idx;
|
return idx;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ed->total == ed->count)
|
if (ed->total == ed->count)
|
||||||
|
@ -117,7 +128,6 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
ed->total = total;
|
ed->total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = strlen(string) + 1;
|
|
||||||
str = strdup(string);
|
str = strdup(string);
|
||||||
if (!str)
|
if (!str)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue