buffer_mmapread(3diet)

buffer_mmapread3diet

Create read-only memory-mapped file buffer

Usage

#include <buffer.h>

int buffer_mmapread(buffer &b,const char* filename);

Overview

buffer_mmapread opens filename for reading and fills b so that the contents of the file can be read from it. Using mmap is more efficient than reading through a real buffer, but you have to call buffer_close to unmap the memory in the end.

Examples

#include <buffer.h>
#include <open.h>

buffer input;
char x;

buffer_mmapread(&input,"/etc/passwd");
while (buffer_get(&input,&x,1)==1) {
buffer_put(buffer_1,&x,1);
if (x=='\n') break;
}
buffer_flush(buffer_1);
buffer_close(&input);

Return value

buffer_mmapread returns 0 if everything was fine, -1 on error (setting errno).

Releases

4 releases since Debian 3.1 (Sarge); the text changed 1 time.

  1. 3.1–4.0
  2. 5.0–6.0

From libowfat-dev 0.28-2 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.