eina_file: make sure we use a stringshare when virtualized.

As the filename is now a stringshare, also make sure virtual
files use stringshares for the filename! Also when unmapping
we still need to test whether it is copied or not as unmap
will break on less tolerant architectures.

@fix T6449
This commit is contained in:
Al Poole 2017-11-30 13:57:25 +00:00
parent 5b113aaa38
commit a538f47854
2 changed files with 3 additions and 3 deletions

View File

@ -300,7 +300,7 @@ eina_file_real_close(Eina_File *file)
if (file->fd != -1)
{
if (file->global_map != MAP_FAILED)
if (!file->copied && file->global_map != MAP_FAILED)
munmap(file->global_map, file->length);
close(file->fd);
}

View File

@ -422,9 +422,9 @@ eina_file_virtualize(const char *virtual_name, const void *data, unsigned long l
EINA_MAGIC_SET(file, EINA_FILE_MAGIC);
file->filename = (char *)(file + 1);
if (virtual_name)
strcpy((char *)file->filename, virtual_name);
file->filename = eina_stringshare_add(virtual_name);
else
sprintf((char *)file->filename, tmpname, ti);
file->filename = eina_stringshare_printf(tmpname, ti);
eina_lock_recursive_new(&file->lock);
file->mtime = ti / 1000;