Function
GLib MappedFilenew_from_fd
since: 2.32
Declaration [src]
GMappedFile*
g_mapped_file_new_from_fd(
gintfd,
gbooleanwritable,
GError**error
)
Description [src]
Maps a file into memory. On UNIX, this is using the mmap() function.
If writable is TRUE, the mapped buffer may be modified, otherwise
it is an error to modify the mapped buffer. Modifications to the buffer
are not visible to other processes mapping the same file, and are not
written back to the file.
Note that modifications of the underlying file might affect the contents
of the GMappedFile. Therefore, mapping should only be used if the file
will not be modified, or if all modifications of the file are done
atomically (e.g. using g_file_set_contents()).
Available since: 2.32
Parameters
fd-
Type:
gintThe file descriptor of the file to load.
writable-
Type:
gbooleanWhether the mapping should be writable.
error-
Type:
The return location for a recoverable error.
The argument can beNULL.If the return location is notNULL, then you must initialize it to aNULLGError*.The argument will be left initialized toNULLby the function if there are no errors.In case of error, the argument will be set to a newly allocatedGError; the caller will take ownership of the data, and be responsible for freeing it.
Return value
Type: GMappedFile
A newly allocated GMappedFile which must be unref’d
with g_mapped_file_unref(), or NULL if the mapping failed.