package core

  1. Overview
  2. No Docs
Industrial strength alternative to OCaml's standard library

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.16.2.tar.gz
md5=bcac85c0ec5795ccabf1dccf0968ecd9
sha512=2e68556773549e0bf302c8733c9fc57df3c0fd73a1b547dc17097f74c5b5482c816ef89853b437e49452da7c124ef32a8a0de0dff64d71145b2ab11befbe5bb2

doc/src/core.heap_block/heap_block.ml.html

Source file heap_block.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open! Base

type 'a t = 'a [@@deriving sexp_of]

external is_heap_block : Stdlib.Obj.t -> bool = "core_heap_block_is_heap_block"
[@@noalloc]

let is_ok v = is_heap_block (Stdlib.Obj.repr v)
let create v = if is_ok v then Some v else None

let create_exn v =
  if is_ok v then v else failwith "Heap_block.create_exn called with non heap block"
;;

let value t = t
let bytes_per_word = Word_size.(num_bits word_size) / 8

let bytes (type a) (t : a t) =
  (Stdlib.Obj.size (Stdlib.Obj.repr (t : a t)) + 1) * bytes_per_word
;;