The comment does say "Allocate struct for eet file and have it zero'd

out" but using calloc is inefficient since most members of the struct
are written to straight away.  Valgrind complains that the data member
can sometimes be used without being initialised.  Seems to happen when
we can't open it and eet_close tests the value of the data member.

Those that know this code better than me should check this. Probably a
good idea to initialise ALL members at this point.


SVN revision: 24848
This commit is contained in:
David Walter Seikel 2006-08-17 20:22:23 +00:00
parent ed7d138bbc
commit 35d34dee92
1 changed files with 2 additions and 3 deletions

View File

@ -536,6 +536,8 @@ eet_open(const char *file, Eet_File_Mode mode)
ef->header = NULL;
ef->mtime = file_stat.st_mtime;
ef->delete_me_now = 0;
ef->data = NULL;
ef->data_size = 0;
/* try open the file based on mode */
if ((ef->mode == EET_FILE_MODE_READ) || (ef->mode == EET_FILE_MODE_READ_WRITE))
@ -556,9 +558,6 @@ eet_open(const char *file, Eet_File_Mode mode)
if (eet_test_close(!ef->fp, ef))
return NULL;
ef->data = NULL;
ef->data_size = 0;
fcntl(fileno(ef->fp), F_SETFD, FD_CLOEXEC);
/* if we opened for read or read-write */
if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))