the rest of cedrics patchesfor fixing dictionaries and read_write

SVN revision: 33969
This commit is contained in:
Carsten Haitzler 2008-03-09 16:16:40 +00:00
parent 4a3d696dcf
commit fcf201dea7
4 changed files with 18 additions and 47 deletions

View File

@ -61,22 +61,23 @@ struct _Eet_String
const char *mmap;
char *str;
struct
{
unsigned int converted : 1;
unsigned int is_float : 1;
} flags;
int hash;
int len;
int next;
int prev;
union
{
float f;
double d;
} convert;
int hash;
int len;
int next;
int prev;
struct
{
unsigned int converted : 1;
unsigned int is_float : 1;
} flags;
};
struct _Eet_Dictionary
{

View File

@ -981,10 +981,6 @@ eet_data_descriptor3_new(Eet_Data_Descriptor_Class *eddc)
edd->func.str_alloc = eddc->func.str_alloc;
if (eddc->func.str_free)
edd->func.str_free = eddc->func.str_free;
if (eddc->func.str_direct_alloc)
edd->func.str_direct_alloc = eddc->func.str_direct_alloc;
if (eddc->func.str_direct_free)
edd->func.str_direct_free = eddc->func.str_direct_free;
edd->func.list_next = eddc->func.list_next;
edd->func.list_append = eddc->func.list_append;
edd->func.list_data = eddc->func.list_data;

View File

@ -20,9 +20,6 @@ eet_dictionary_add(void)
if (!new)
return NULL;
new->count = 0;
new->total = 0;
memset(new->hash, -1, sizeof (int) * 256);
return new;

View File

@ -29,6 +29,7 @@ struct _Eet_File
{
char *path;
FILE *fp;
FILE *readfp;
Eet_File_Header *header;
const unsigned char *data;
Eet_Dictionary *ed;
@ -818,6 +819,7 @@ eet_internal_read2(Eet_File *ef)
if (eet_test_close(!ef->ed->all, ef)) return NULL;
ef->ed->count = num_dictionary_entries;
ef->ed->total = num_dictionary_entries;
ef->ed->start = start + bytes_dictionary_entries + bytes_directory_entries;
ef->ed->end = ef->ed->start;
@ -1092,6 +1094,7 @@ eet_open(const char *file, Eet_File_Mode mode)
if (ef)
{
eet_flush2(ef);
ef->references++;
ef->delete_me_now = 1;
eet_close(ef);
}
@ -1104,6 +1107,7 @@ eet_open(const char *file, Eet_File_Mode mode)
if (ef)
{
ef->delete_me_now = 1;
ef->references++;
eet_close(ef);
}
ef = eet_cache_find((char *)file, eet_writers, eet_writers_num);
@ -1159,6 +1163,7 @@ eet_open(const char *file, Eet_File_Mode mode)
/* fill some of the members */
ef->fp = fp;
ef->readfp = NULL;
ef->path = ((char *)ef) + sizeof(Eet_File);
strcpy(ef->path, file);
ef->magic = EET_MAGIC_FILE;
@ -1193,35 +1198,7 @@ eet_open(const char *file, Eet_File_Mode mode)
/* we need to delete the original file in read-write mode and re-open for writing */
if (ef->mode == EET_FILE_MODE_READ_WRITE)
{
int i;
for (i = 0; i < ef->header->directory->size; i++)
{
Eet_File_Node *efn;
for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
{
if (!efn->free_name)
{
efn->free_name = 1;
efn->name = strdup(efn->name);
}
}
}
if (ef->ed)
{
for (i = 0; i < ef->ed->count; ++i)
{
if (ef->ed->all[i].mmap)
{
ef->ed->all[i].str = strdup(ef->ed->all[i].mmap);
ef->ed->all[i].mmap = NULL;
}
}
}
fclose(ef->fp);
ef->readfp = ef->fp;
unlink(ef->path);
ef->fp = fopen(ef->path, "wb");
}
@ -1311,8 +1288,8 @@ eet_close(Eet_File *ef)
eet_dictionary_free(ef->ed);
if (ef->data) munmap((void*)ef->data, ef->data_size);
if (ef->fp) fclose(ef->fp);
if (ef->readfp) fclose(ef->readfp);
/* zero out ram for struct - caution tactic against stale memory use */
memset(ef, 0, sizeof(Eet_File));