package io-page

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

Module Io_pageSource

Memory allocation.

Memory allocation interface.

Sourcetype buf = Cstruct.t

Type of a C buffer (in this case, a Cstruct)

Type of memory blocks.

Sourceval page_size : int

Size of one page of memory in bytes.

Sourceval get_addr : t -> nativeint

get_addr t returns the address of the underlying bigarray of t. This is useful for debugging

Sourceval get_page : t -> nativeint

get_page t returns the page offset (get_addr t) mod page_size, starting at 0 .

Sourceval get : int -> t

get n allocates and returns a memory block of n pages. If there is not enough memory, an Out_of_memory exception is raised. Note that this may be a recoverable situation, since this function allocates memory from a page-aligned pool, whereas the OCaml garbage collector will be running in its own heap that may have spare memory despite the Out_of_memory being raised from this function call.

Sourceval get_buf : ?n:int -> unit -> buf

get_buf n allocates and returns a memory block of n pages, represented as a Cstruct.t. If there is not enough memory, an Out_of_memory exception is raised.

Sourceval get_order : int -> t

get_order i is get (1 lsl i).

Sourceval pages : int -> t list

pages n allocates a memory block of n pages and return the list of pages allocated.

Sourceval pages_order : int -> t list

pages_order i is pages (1 lsl i).

Sourceval length : t -> int

length t is the size of t, in bytes.

Sourceval to_cstruct : t -> buf

to_cstruct t generates a Cstruct.t that covers the entire Io_page.

Sourceexception Buffer_is_not_page_aligned
Sourceexception Buffer_not_multiple_of_page_size
Sourceval of_cstruct_exn : buf -> t

of_cstruct t converts a page-aligned buffer back to an Io_page. It raises Buffer_is_not_page_aligned if t is not page aligned or Buffer_not_multiple_of_page_size if t is not a whole number of pages in length. TODO: currently assumes the underlying Bigarray is page aligned.

Sourceval to_string : t -> string

to_string t will allocate a fresh string and copy the contents of t into the string.

Sourceval to_pages : t -> t list

to_pages t is a list of size memory blocks of one page each, where size is the size of t in pages.

Sourceval string_blit : string -> int -> t -> int -> int -> unit

string_blit src srcoff dst dstoff len copies len bytes from string src, starting at byte number srcoff, to memory block dst, starting at byte number dstoff.

Sourceval blit : t -> t -> unit

blit t1 t2 is the same as Bigarray.Array1.blit.

Sourceval round_to_page_size : int -> int

round_to_page_size n returns the number of bytes that will be allocated for storing n bytes in memory

OCaml

Innovation. Community. Security.