Skip to content

Commit

Permalink
access the buffer via primitives
Browse files Browse the repository at this point in the history
fix #194
  • Loading branch information
pqwy committed Dec 13, 2017
1 parent 6aaed48 commit 5f326e8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/cstruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,12 @@ let get_char t i =
else Bigarray.Array1.get t.buffer (t.off+i)


external ba_set_int16 : buffer -> int -> uint16 -> unit = "caml_ba_uint8_set16"
external ba_set_int32 : buffer -> int -> uint32 -> unit = "caml_ba_uint8_set32"
external ba_set_int64 : buffer -> int -> uint64 -> unit = "caml_ba_uint8_set64"
external ba_get_int16 : buffer -> int -> uint16 = "caml_ba_uint8_get16"
external ba_get_int32 : buffer -> int -> uint32 = "caml_ba_uint8_get32"
external ba_get_int64 : buffer -> int -> uint64 = "caml_ba_uint8_get64"
external ba_set_int16 : buffer -> int -> uint16 -> unit = "%caml_bigstring_set16"
external ba_set_int32 : buffer -> int -> uint32 -> unit = "%caml_bigstring_set32"
external ba_set_int64 : buffer -> int -> uint64 -> unit = "%caml_bigstring_set64"
external ba_get_int16 : buffer -> int -> uint16 = "%caml_bigstring_get16"
external ba_get_int32 : buffer -> int -> uint32 = "%caml_bigstring_get32"
external ba_get_int64 : buffer -> int -> uint64 = "%caml_bigstring_get64"

external swap16 : int -> int = "%bswap16"
external swap32 : int32 -> int32 = "%bswap_int32"
Expand Down Expand Up @@ -304,11 +304,11 @@ let len t =
t.len

(** [sum_lengths ~caller acc l] is [acc] plus the sum of the lengths
of the elements of [l]. Raises [Invalid_argument caller] if
of the elements of [l]. Raises [Invalid_argument caller] if
arithmetic overflows. *)
let rec sum_lengths_aux ~caller acc = function
| [] -> acc
| h :: t ->
| h :: t ->
let sum = len h + acc in
if sum < acc then invalid_arg caller
else sum_lengths_aux ~caller sum t
Expand Down

0 comments on commit 5f326e8

Please sign in to comment.