From: David Scott Date: Tue, 12 Oct 2010 11:09:56 +0000 (+0100) Subject: CA-44731: Add Fring.copy, needed in order to write an RRD copy function. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e9c5e4f55e5d5c6be6110618a4735f11539febbc;p=xcp%2Fxen-api-libs.git CA-44731: Add Fring.copy, needed in order to write an RRD copy function. Signed-off-by: David Scott --- diff --git a/stdext/fring.ml b/stdext/fring.ml index 4b64ebf..e6b5fbd 100644 --- a/stdext/fring.ml +++ b/stdext/fring.ml @@ -23,6 +23,13 @@ let make size init = done; ring +let copy x = + let y = make x.size 0. in + for i = 0 to Bigarray.Array1.dim x.data - 1 do + Bigarray.Array1.set y.data i (Bigarray.Array1.get x.data i) + done; + y + let length ring = ring.size let push ring e = diff --git a/stdext/fring.mli b/stdext/fring.mli index 38a60d1..c14aa50 100644 --- a/stdext/fring.mli +++ b/stdext/fring.mli @@ -22,6 +22,9 @@ type t = { (** create a ring structure with [size] record; records initialised to [init] *) val make : int -> float -> t +(** create a duplicate ring structure *) +val copy : t -> t + (** length of the ring *) val length : t -> int