From 35d34dee9273663678f4aba904288d1f39f022de Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 17 Aug 2006 20:22:23 +0000 Subject: [PATCH] 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 --- legacy/eet/src/lib/eet_lib.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/legacy/eet/src/lib/eet_lib.c b/legacy/eet/src/lib/eet_lib.c index bbfb031241..9839e44097 100644 --- a/legacy/eet/src/lib/eet_lib.c +++ b/legacy/eet/src/lib/eet_lib.c @@ -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))