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:
-
char *
ptr -
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:
-
char *
start of the buffer -
size
of the buffer -
free
of the buffer
-
- fixbuf.new(sz)
-
Creates buffer from range 4K - 1M.
Parameters:
- sz requested size
Returns:
Raises:
ifsz
is bigger than 1M