for (i = 0; i < ed->count; ++i)
if (ed->all[i].allocated)
- free(ed->all[i].u.str);
+ eina_stringshare_del(ed->all[i].str);
if (ed->all)
free(ed->all);
{
if (ed->all[current].len == len)
{
- if (ed->all[current].allocated)
+ if (ed->all[current].str &&
+ (ed->all[current].str == string || strcmp(ed->all[current].str, string) == 0))
{
- if (strcmp(ed->all[current].u.str, string) == 0)
- {
- found = EINA_TRUE;
- break;
- }
+ found = EINA_TRUE;
+ break;
}
- else if (ed->all[current].u.mmap
- && strcmp(ed->all[current].u.mmap, string) == 0)
- {
- found = EINA_TRUE;
- break;
- }
}
prev = current;
const char *string)
{
Eet_String *current;
- char *str;
+ const char *str;
int hash;
int idx;
int len;
if (idx != -1)
{
- if (ed->all[idx].allocated)
- {
- if (strcmp(ed->all[idx].u.str, string) == 0)
- return idx;
- }
- else if (ed->all[idx].u.mmap && strcmp(ed->all[idx].u.mmap, string) == 0)
+ if (ed->all[idx].str && (ed->all[idx].str == string || strcmp(ed->all[idx].str, string) == 0))
return idx;
}
ed->total = total;
}
- str = strdup(string);
+ str = eina_stringshare_add(string);
if (!str)
return -1;
current->hash = hash;
- current->u.str = str;
+ current->str = str;
current->len = len;
if (idx == -1)
/* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */
if (!ed->all[idx].allocated)
{
- ed->all[idx].u.str = strdup(ed->all[idx].u.mmap);
+ ed->all[idx].str = strdup(ed->all[idx].str);
ed->all[idx].allocated = EINA_TRUE;
}
-
-#else /* ifdef _WIN32 */
- if (!(ed->all[idx].allocated) && ed->all[idx].u.mmap)
- return ed->all[idx].u.mmap;
-
#endif /* ifdef _WIN32 */
- return ed->all[idx].u.str;
+ return ed->all[idx].str;
}
return NULL;
{
Eet_Convert *result;
- *str = ed->all[idx].allocated ? ed->all[idx].u.str : ed->all[idx].u.mmap;
+ *str = ed->all[idx].str;
if (!ed->converts)
{
return 1;
for (i = 0; i < ed->count; ++i)
- if ((ed->all[i].allocated) && ed->all[i].u.str == string)
+ if ((ed->all[i].allocated) && ed->all[i].str == string)
return 1;
return 0;
if (ef->ed)
for (j = 0; j < ef->ed->count; ++j)
{
- if (ef->ed->all[j].allocated)
- {
- if (fwrite(ef->ed->all[j].u.str, ef->ed->all[j].len, 1, fp) != 1)
- goto write_error;
- }
- else if (fwrite(ef->ed->all[j].u.mmap, ef->ed->all[j].len, 1, fp) != 1)
- goto write_error;
+ if (fwrite(ef->ed->all[j].str, ef->ed->all[j].len, 1, fp) != 1)
+ goto write_error;
}
/* write data */
ef->data_size)), ef))
return NULL;
- ef->ed->all[j].u.mmap = start + offset;
+ ef->ed->all[j].str = start + offset;
- if (ef->ed->all[j].u.mmap + ef->ed->all[j].len > ef->ed->end)
- ef->ed->end = ef->ed->all[j].u.mmap + ef->ed->all[j].len;
+ if (ef->ed->all[j].str + ef->ed->all[j].len > ef->ed->end)
+ ef->ed->end = ef->ed->all[j].str + ef->ed->all[j].len;
/* Check '\0' at the end of the string */
- if (eet_test_close(ef->ed->all[j].u.mmap[ef->ed->all[j].len - 1] !=
+ if (eet_test_close(ef->ed->all[j].str[ef->ed->all[j].len - 1] !=
'\0', ef))
return NULL;