Memory-mapped files
Constants
Error codes
VALUES
-
MME_OK - - everything went fine
-
MME_INVALID_FLAG - - invalid mmfl value
-
MME_OPEN_ERROR - - failed to open file
-
MME_MMAP_ERROR - - failed to create memory mapping
#define MME_OK 0 #define MME_INVALID_FLAG -1 #define MME_OPEN_ERROR -2 #define MME_MMAP_ERROR -3
MMF_MAP_ALL
Offset value to map entire file into memory
#define MMF_MAP_ALL -1
Memory mapping protection flags
VALUES
-
MMFL_RDONLY - map read only
-
MMFL_WRONLY - map write only
-
MMFL_RDWR - allows both write and reads
#define MMFL_RDONLY #define MMFL_WRONLY #define MMFL_RDWR
Functions
mmf_open
publicplat
Initialize mmap_file_t structure and open file
ARGUMENTS
-
mmf - pointer to mmap_file_t
-
filename - path to file
-
mmfl - memory mapping flag
RETURN VALUES
MME_OK if file was successfully opened or MME_OPEN_ERROR
LIBEXPORT PLATAPI int mmf_open(mmap_file_t* mmf, const char* filename, int mmfl)
mmf_close
publicplat
Close memory-mapped file
ARGUMENTS
-
mmf - pointer to mmap_file_t
LIBEXPORT PLATAPI void mmf_close(mmap_file_t* mmf)
mmf_create
publicplat
ARGUMENTS
-
mmf - pointer to mmap_file_t
-
offset - offset inside file
-
length - length of mapping area
-
mapping_ptr - pointer to pointer to mapping area
RETURN VALUES
MME_OK if mapping was successfully mapped, or MME_MMAP_ERROR/MME_INVALID_FLAG
LIBEXPORT PLATAPI int mmf_create(mmap_file_t* mmf, long long offset, size_t length, void** mapping_ptr)
mmf_destroy
publicplat
Unmap file area
ARGUMENTS
-
mmf - pointer to mmap_file_t
-
mapping - pointer to mapping returned earliear by mmf_create
LIBEXPORT PLATAPI void mmf_destroy(mmap_file_t* mmf, void* mapping)