Changeset - r9702:6f5b71553617
[Not reviewed]
master
0 2 0
rubidium - 16 years ago 2008-07-23 21:42:55
rubidium@openttd.org
(svn r13810) -Fix: small memory leak when tar files would be found.
2 files changed with 10 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -337,7 +337,7 @@ FILE *FioFOpenFileSp(const char *filenam
 

	
 
FILE *FioFOpenFileTar(TarFileListEntry *entry, size_t *filesize)
 
{
 
	FILE *f = fopen(entry->tar->filename, "rb");
 
	FILE *f = fopen(entry->tar_filename, "rb");
 
	assert(f != NULL);
 

	
 
	fseek(f, entry->position, SEEK_SET);
 
@@ -513,9 +513,8 @@ static bool TarListAddFile(const char *f
 
	FILE *f = fopen(filename, "rb");
 
	assert(f != NULL);
 

	
 
	TarListEntry *tar_entry = MallocT<TarListEntry>(1);
 
	tar_entry->filename = strdup(filename);
 
	_tar_list.insert(TarList::value_type(filename, tar_entry));
 
	const char *dupped_filename = strdup(filename);
 
	_tar_list[filename].filename = dupped_filename;
 

	
 
	TarLinkList links; ///< Temporary list to collect links
 

	
 
@@ -575,9 +574,9 @@ static bool TarListAddFile(const char *f
 

	
 
				/* Store this entry in the list */
 
				TarFileListEntry entry;
 
				entry.tar      = tar_entry;
 
				entry.size     = skip;
 
				entry.position = pos;
 
				entry.tar_filename = dupped_filename;
 
				entry.size         = skip;
 
				entry.position     = pos;
 

	
 
				/* Convert to lowercase and our PATHSEPCHAR */
 
				SimplifyFileName(name);
src/tar_type.h
Show inline comments
 
@@ -11,15 +11,17 @@
 
/** The define of a TarList. */
 
struct TarListEntry {
 
	const char *filename;
 

	
 
	~TarListEntry() { free((void*)this->filename); }
 
};
 

	
 
struct TarFileListEntry {
 
	TarListEntry *tar;
 
	const char *tar_filename;
 
	size_t size;
 
	size_t position;
 
};
 

	
 
typedef std::map<std::string, TarListEntry *> TarList;
 
typedef std::map<std::string, TarListEntry> TarList;
 
typedef std::map<std::string, TarFileListEntry> TarFileList;
 
extern TarList _tar_list;
 
extern TarFileList _tar_filelist;
0 comments (0 inline, 0 general)