Skip to content

Commit

Permalink
Comment references to bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
thierry-martinez committed Nov 18, 2017
1 parent ddcab19 commit 20695e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions bytearray.ml
Expand Up @@ -37,20 +37,22 @@ let unsafe_blit_to_string a i s j l =

external unsafe_blit_from_string : string -> int -> t -> int -> int -> unit
= "ml_blit_string_to_bigarray" "noalloc"

(*
external unsafe_blit_to_bytes : t -> int -> bytes -> int -> int -> unit
= "ml_blit_bigarray_to_string" "noalloc"

*)
(*
let unsafe_sub a ofs len =
let s = Bytes.create len in
unsafe_blit_to_bytes a ofs s 0 len;
Bytes.to_string s

*)
(*
let to_string a =
let l = length a in
if l > Sys.max_string_length then invalid_arg "Bytearray.to_string" else
unsafe_sub a 0 l

*)
let of_string s =
let l = String.length s in
let a = create l in
Expand All @@ -62,15 +64,15 @@ let mmap_of_string fd s =
let ba = Bigarray.Array1.map_file fd Bigarray.char Bigarray.c_layout true l in
unsafe_blit_from_string s 0 ba 0 l;
ba

(*
let sub a ofs len =
if
ofs < 0 || len < 0 || ofs > length a - len || len > Sys.max_string_length
then
invalid_arg "Bytearray.sub"
else
unsafe_sub a ofs len

*)
let rec prefix_rec a i a' i' l =
l = 0 ||
(a.{i} = a'.{i'} && prefix_rec a (i + 1) a' (i' + 1) (l - 1))
Expand All @@ -86,13 +88,13 @@ let blit_from_string s i a j l =
|| j < 0 || j > length a - l
then invalid_arg "Bytearray.blit_from_string"
else unsafe_blit_from_string s i a j l

(*
let blit_to_bytes a i s j l =
if l < 0 || i < 0 || i > length a - l
|| j < 0 || j > Bytes.length s - l
then invalid_arg "Bytearray.blit_to_bytes"
else unsafe_blit_to_bytes a i s j l

*)
external marshal : 'a -> Marshal.extern_flags list -> t
= "ml_marshal_to_bigarray"

Expand Down
12 changes: 6 additions & 6 deletions bytearray.mli
Expand Up @@ -18,9 +18,9 @@ type tf =
val create : int -> t

val length : t -> int

(*
val to_string : t -> string

*)
val of_string : string -> t

val mmap_of_string : Unix.file_descr -> string -> t
Expand All @@ -30,13 +30,13 @@ val to_floatarray : tf -> int -> float array
val to_this_floatarray : float array -> tf -> int -> float array

val of_floatarray : float array -> tf

(*
val sub : t -> int -> int -> string

*)
val blit_from_string : string -> int -> t -> int -> int -> unit

(*
val blit_to_bytes : t -> int -> bytes -> int -> int -> unit

*)
val prefix : t -> t -> int -> bool

val marshal : 'a -> Marshal.extern_flags list -> t
Expand Down

1 comment on commit 20695e4

@rdicosmo
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Thierry

Please sign in to comment.