package memcpy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Efficient copies between various types of memory blocks: bytes, bigarrays, addresses and arrays

type safe

The types of memory are divided into two classes: safe, where the bounds can be checked, and unsafe, where no bounds information is available.

and unsafe
type ('safe, 'typ) spec

A specification for the type of memory involved in the copy.

val ocaml_bytes : (safe, Stdlib.Bytes.t) spec

A specification for OCaml's bytes type

val bigarray : < ba_repr : 'a ; bigarray : 'b ; carray : 'c ; dims : 'd ; element : 'e > Ctypes.bigarray_class -> 'd -> ('e, 'a) Stdlib.Bigarray.kind -> (safe, 'b) spec

A specification for a bigarray type

val pointer : (unsafe, _ Ctypes.ptr) spec

A specification for a Ctypes pointer type

val carray : (safe, _ Ctypes.carray) spec

A specification for a Ctypes array type

val memcpy : (safe, 's) spec -> (safe, 'd) spec -> src:'s -> dst:'d -> ?src_off:int -> ?dst_off:int -> len:int -> unit

memcpy s d ~src ~dst ~src_off ~dst_off ~len copies len bytes from offset src_off of src to offset dst_off of dst.

  • raises [Invalid_argument

    "Memcpy.memcpy"] if the memory between src_off and src_off + len does not fall within src or if the memory between dst_off and dst_off + len does not fall within dst.

val unsafe_memcpy : (_, 's) spec -> (_, 'd) spec -> src:'s -> dst:'d -> ?src_off:int -> ?dst_off:int -> len:int -> unit

unsafe_memcpy s d ~src ~dst ~src_off ~dst_off ~len copies len bytes from offset src_off of src to offset dst_off of dst.

No attempt is made to check that the specified regions of memory actually fall within src and dst.

val memcpy_from_string : (safe, 'd) spec -> src:string -> ?dst_off:int -> dst:'d -> unit

memcpy_from_string d ~src ~dst ~dst_off copies src to offset dst_off of dst.

  • raises [Invalid_argument

    "Memcpy.memcpy"] if the memory between dst_off and dst_off + len does not fall within dst.

val memcpy_from_bytes : (safe, 'd) spec -> src:Stdlib.Bytes.t -> ?dst_off:int -> dst:'d -> unit

memcpy_from_bytes d ~src ~dst ~dst_off copies src to offset dst_off of dst.

  • raises [Invalid_argument

    "Memcpy.memcpy"] if the memory between dst_off and dst_off + len does not fall within dst.

OCaml

Innovation. Community. Security.