chunk is an offset into a region of memory allocated from some region
t. It is of a length set when the region
t associated with it was initialised.
init ~block_size buf slots initialises a region from the buffer
buf with total size of
block_size * slots.
val free : chunk -> unit
free chunk will return the memory
chunk back to the region
t where it can be reallocated.
val length : chunk -> int
length chunk is the block size.
val to_offset : chunk -> int
to_offset chunk will convert the
chunk into an integer offset in its associated region. This can be used in IO calls involving that memory.
to_cstruct chunk is a cstruct of
chunk's slice of the region. Note that this is a zero-copy view into the underlying region
t and so
chunk should not be freed until this cstruct is no longer used.
val to_string : ?len:int -> chunk -> string
to_string ?len chunk will return a copy of
chunk as an OCaml string.
val avail : t -> int
avail t is the number of free chunks of memory remaining in the region.