mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-23 04:36:17 +01:00
Return NULL from g_mapped_file_get_contents()
In the case of an empty file, return NULL instead of "". This means that the return result of g_mapped_file_get_contents() will always be page-aligned.
This commit is contained in:
parent
2a19bb7699
commit
b0a0ac51cb
@ -39,6 +39,11 @@ Notes about GLib 2.24
|
|||||||
while an object is being initialized. If this behavior is needed, setting a
|
while an object is being initialized. If this behavior is needed, setting a
|
||||||
custom constructor that just chains up will re-enable this functionality.
|
custom constructor that just chains up will re-enable this functionality.
|
||||||
|
|
||||||
|
* GMappedFile on an empty file now returns NULL for the contents instead of
|
||||||
|
returning an empty string. The documentation specifically states that code
|
||||||
|
may not rely on nul-termination here so any breakage caused by this change
|
||||||
|
is a bug in application code.
|
||||||
|
|
||||||
Notes about GLib 2.22
|
Notes about GLib 2.22
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ g_mapped_file_new (const gchar *filename,
|
|||||||
if (st.st_size == 0)
|
if (st.st_size == 0)
|
||||||
{
|
{
|
||||||
file->length = 0;
|
file->length = 0;
|
||||||
file->contents = "";
|
file->contents = NULL;
|
||||||
close (fd);
|
close (fd);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
@ -242,7 +242,9 @@ g_mapped_file_get_length (GMappedFile *file)
|
|||||||
* Note that the contents may not be zero-terminated,
|
* Note that the contents may not be zero-terminated,
|
||||||
* even if the #GMappedFile is backed by a text file.
|
* even if the #GMappedFile is backed by a text file.
|
||||||
*
|
*
|
||||||
* Returns: the contents of @file.
|
* If the file is empty then %NULL is returned.
|
||||||
|
*
|
||||||
|
* Returns: the contents of @file, or %NULL.
|
||||||
*
|
*
|
||||||
* Since: 2.8
|
* Since: 2.8
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user