mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
Make mapping of empty files work. (#321530)
2005-12-03 Matthias Clasen <mclasen@redhat.com> * glib/gmappedfile.c: Make mapping of empty files work. (#321530)
This commit is contained in:
parent
9f4e58980d
commit
d87c91a396
@ -1,5 +1,8 @@
|
|||||||
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gmappedfile.c: Make mapping of empty files
|
||||||
|
work. (#321530)
|
||||||
|
|
||||||
* glib/gfileutils.c: Don't fork a new process just to
|
* glib/gfileutils.c: Don't fork a new process just to
|
||||||
fix the permissions of the created temp file. (#321318,
|
fix the permissions of the created temp file. (#321318,
|
||||||
Alexis S. L. Carvalho)
|
Alexis S. L. Carvalho)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gmappedfile.c: Make mapping of empty files
|
||||||
|
work. (#321530)
|
||||||
|
|
||||||
* glib/gfileutils.c: Don't fork a new process just to
|
* glib/gfileutils.c: Don't fork a new process just to
|
||||||
fix the permissions of the created temp file. (#321318,
|
fix the permissions of the created temp file. (#321318,
|
||||||
Alexis S. L. Carvalho)
|
Alexis S. L. Carvalho)
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
2005-12-03 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* glib/gmappedfile.c: Make mapping of empty files
|
||||||
|
work. (#321530)
|
||||||
|
|
||||||
* glib/gfileutils.c: Don't fork a new process just to
|
* glib/gfileutils.c: Don't fork a new process just to
|
||||||
fix the permissions of the created temp file. (#321318,
|
fix the permissions of the created temp file. (#321318,
|
||||||
Alexis S. L. Carvalho)
|
Alexis S. L. Carvalho)
|
||||||
|
@ -137,6 +137,14 @@ g_mapped_file_new (const gchar *filename,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (st.st_size == 0)
|
||||||
|
{
|
||||||
|
file->length = 0;
|
||||||
|
file->contents = "";
|
||||||
|
close (fd);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
file->contents = MAP_FAILED;
|
file->contents = MAP_FAILED;
|
||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
@ -251,13 +259,16 @@ g_mapped_file_free (GMappedFile *file)
|
|||||||
{
|
{
|
||||||
g_return_if_fail (file != NULL);
|
g_return_if_fail (file != NULL);
|
||||||
|
|
||||||
|
if (file->length)
|
||||||
|
{
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
munmap (file->contents, file->length);
|
munmap (file->contents, file->length);
|
||||||
#endif
|
#endif
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
UnmapViewOfFile (file->contents);
|
UnmapViewOfFile (file->contents);
|
||||||
CloseHandle (file->mapping);
|
CloseHandle (file->mapping);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
g_free (file);
|
g_free (file);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user