module Unsafe_common:sig
..end
USE WITH CAUTION!
type
sptr
type
eptr
type
sptr_ptr
val get_sptr : Common.buf -> pos:Common.pos -> sptr
get_sptr buf ~pos
buf
and start position pos
.val get_eptr : Common.buf -> pos:Common.pos -> eptr
get_eptr buf ~pos
buf
and end position pos
.val shift_sptr : sptr -> int -> sptr
shift_sptr sptr n
sptr
by n
characters.val get_eptr_from_sptr_ptr : sptr_ptr -> pos:Common.pos -> eptr
get_eptr_from_sptr_ptr sptr_ptr ~pos
pos
after location sptr_ptr
.val get_buf_pos : start:sptr -> cur:sptr -> Common.pos
get_buf_pos ~start ~cur
start
and cur
.val get_safe_buf_pos : Common.buf ->
start:sptr -> cur:sptr -> Common.pos
get_safe_buf_pos buf ~start ~cur
start
and cur
. buf
is
ignored, but prevents the buffer from being reclaimed by the GC,
which it needs to until this function gets called.val alloc_sptr_ptr : Common.buf -> pos:Common.pos -> sptr_ptr
alloc_sptr_ptr buf ~pos
allocate a pointer to a start pointer.
NOTE: do not forget to deallocate it, otherwise there will be a
space leak!
NOTE: The "noalloc" attribute is correct, because it indicates
there is no OCaml allocation. alloc_sptr_ptr
only does C
allocation.val dealloc_sptr_ptr : Common.buf -> sptr_ptr -> Common.pos
dealloc_sptr_ptr buf sptr_ptr
deallocate a pointer to a start
pointer and return its position. NOTE: do not do this more than
once, otherwise the program may crash!val get_sptr_ptr : sptr_ptr -> Common.buf -> Common.pos
get_sptr_ptr sptr_ptr buf
buf
denoted by the pointer stored in sptr_ptr
.val set_sptr_ptr : sptr_ptr -> Common.buf -> pos:Common.pos -> unit
set_sptr_ptr sptr_ptr buf ~pos
sets the pointer in sptr_ptr
to the location denoted by position pos
in buffer buf
.val get_sptr_ptr_sptr : sptr_ptr -> sptr
get_sptr_ptr_sptr sptr_ptr
sptr_ptr
.val set_sptr_ptr_sptr : sptr_ptr -> sptr -> unit
set_sptr_ptr_sptr sptr_ptr sptr
sets the pointer in
sptr_ptr
to sptr
.val get_ptr_string : sptr -> eptr -> string
get_ptr_string sptr_ptr eptr
sptr
to end pointer eptr
.val get_read_init : Common.buf ->
pos_ref:Common.pos Pervasives.ref ->
sptr_ptr * eptr
get_read_init buf ~pos_ref
sptr_ptr
denoting the
start and the eptr
denoting the end of buffer buf
. NOTE: do
not forget to deallocate the sptr_ptr
!