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
fix the permissions of the created temp file. (#321318,
Alexis S. L. Carvalho)
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
fix the permissions of the created temp file. (#321318,
Alexis S. L. Carvalho)
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
fix the permissions of the created temp file. (#321318,
Alexis S. L. Carvalho)
goto out;
}
+ if (st.st_size == 0)
+ {
+ file->length = 0;
+ file->contents = "";
+ close (fd);
+ return file;
+ }
+
file->contents = MAP_FAILED;
#ifdef HAVE_MMAP
{
g_return_if_fail (file != NULL);
+ if (file->length)
+ {
#ifdef HAVE_MMAP
- munmap (file->contents, file->length);
+ munmap (file->contents, file->length);
#endif
#ifdef G_OS_WIN32
- UnmapViewOfFile (file->contents);
- CloseHandle (file->mapping);
+ UnmapViewOfFile (file->contents);
+ CloseHandle (file->mapping);
#endif
+ }
g_free (file);
}