logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

lc_mmapfile - map or unmap files or devices into memory

Description

       The  lc_mmapfile()  function  is  a  convenience  wrapper for mmap(2) which open(2)s and maps a file in a
       single call. See mmap(2) for a full description.

       If prot has the PROT_WRITE flag set, pathname is open(2)'ed with the O_RDWR and O_CREAT  flags  set  (the
       file  is  created and opened read-write), otherwise it is opened O_RDONLY.  The mode for the created file
       can be set by setting st_mode in sb when calling lc_mmapfile().

       If len points to a value greater than zero, ftruncate(2) is called to truncate the file to the  specified
       length. Otherwise, the variable len points to is set to the size of the file.

       When done, the file can be unmapped and the memory freed by calling munmap(3).

Errors

ENODATA
              File is zero length.

       See also open(2), mmap(2), fstat(2), and ftruncate(2).

Library

       Librecast library (liblibrecast, -llibrecast)

Name

       lc_mmapfile - map or unmap files or devices into memory

Return Value

       On  success, lc_mmapfile() returns a pointer to the mapped area. On error, the value MAP_FAILED (that is,
       (void*)-1 ) is returned, and errno is set to indicate the error.

See Also

mmap(2), msync(2), munmap(2), open(2), fstat(2), ftruncate(2)

LIBRECAST                                          2023-07-24                                     LC_MMAPFILE(3)

Synopsis

#include<librecast/sync.h>void*lc_mmapfile(constchar*pathname,size_t*len,intprot,intflags,off_toffset,structstat*sb);

       Compile and link with -llibrecast.

See Also