bugfix in CCRingBuffer (syntax?)

This commit is contained in:
Simon Cruanes 2015-02-25 23:08:03 +01:00
parent fe234e3dba
commit 536f3152af

View file

@ -63,7 +63,7 @@ module Array = struct
end end
module Byte : module Byte :
S with type elt = char and type t = bytes = struct S with type elt = char and type t = Bytes.t = struct
type elt = char type elt = char
include Bytes include Bytes
end end
@ -286,18 +286,14 @@ module MakeFromArray(Array:Array.S) = struct
assert (cap >= Array.length b.buf); assert (cap >= Array.length b.buf);
let buf' = Array.make cap elem in let buf' = Array.make cap elem in
(* copy into buf' *) (* copy into buf' *)
let _:int = if b.stop >= b.start
if b.stop >= b.start then
then begin Array.blit b.buf b.start buf' 0 (b.stop - b.start)
Array.blit b.buf b.start buf' 0 (b.stop - b.start); else begin
b.stop - b.start let len_end = Array.length b.buf - b.start in
end else begin Array.blit b.buf b.start buf' 0 len_end;
let len_end = Array.length b.buf - b.start in Array.blit b.buf 0 buf' len_end b.stop;
Array.blit b.buf b.start buf' 0 len_end; end;
Array.blit b.buf 0 buf' len_end b.stop;
len_end + b.stop
end
in
b.buf <- buf' b.buf <- buf'
let blit_from_bounded b from_buf o len = let blit_from_bounded b from_buf o len =