Module bin.fixbuf

This module provides buffer with constant capacity.

Module implements every method from bin.basebuf

Example of usage moonlibs/connection-scribe

Class fixbuf

buf:pv() Returns raw pointer Doesn't grant ownership.
buf:export() Returns raw pointer, size and free of the buffer and destroys buffer.
fixbuf.new(sz) Creates buffer from range 4K - 1M.


Class fixbuf

Implements write buffer. Has following structure inside

struct bin_buf_#capasity {
      char   buf[#capasity];
      size_t cur;
};
buf:pv()
Returns raw pointer Doesn't grant ownership.

You can't continue to use pointer after buffer modification or after free of original object

Mind GC!

Returns:

  1. char * ptr
  2. size of written data
buf:export()
Returns raw pointer, size and free of the buffer and destroys buffer.

Grants ownership of struct to the returned value (including gc) use object after export is prohibited

Returns:

  1. char * start of the buffer
  2. size of the buffer
  3. free of the buffer
fixbuf.new(sz)
Creates buffer from range 4K - 1M.

Parameters:

  • sz requested size

Returns:

    fixbuf

Raises:

if sz is bigger than 1M
generated by LDoc 1.4.6 Last updated 2022-05-19 12:17:27