nvm_buf - Buffer Allocation

nvm_buf_to_file

int nvm_buf_to_file(char * buf, size_t nbytes, const char * path)

Write content of buffer into file.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • buf: Pointer to the buffer
  • nbytes: Size of buf
  • path: Destination where buffer will be dumped to

nvm_buf_from_file

int nvm_buf_from_file(char * buf, size_t nbytes, const char * path)

Read content of file into buffer.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • buf: Pointer to the buffer
  • nbytes: Size of buf
  • path: Source to read from

nvm_buf_alloc

void* nvm_buf_alloc(const struct nvm_geo * geo, size_t nbytes)

Allocate a buffer aligned to match the given geometry.

Note
nbytes must be greater than zero and a multiple of minimal granularity
Return
A pointer to the allocated memory. On error: NULL is returned and errno set appropriatly
Parameters
  • geo: The geometry to get alignment information from
  • nbytes: The size of the allocated buffer in bytes

nvm_buf_fill

void nvm_buf_fill(char * buf, size_t nbytes)

Fills buf with chars A-Z.

Parameters
  • buf: Pointer to the buffer to fill
  • nbytes: Amount of bytes to fill in buf

nvm_buf_pr

void nvm_buf_pr(char * buf, size_t nbytes)

Prints buf to stdout.

Parameters
  • buf: Pointer to the buffer to print
  • nbytes: Amount of bytes of buf to print