WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH] add handy substring type

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH] add handy substring type
From: David Scott <dave.scott@xxxxxxxxxxxxx>
Date: Mon, 23 Aug 2010 13:59:23 +0100
Delivery-date: Mon, 23 Aug 2010 06:20:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
# HG changeset patch
# User David Scott <dave.scott@xxxxxxxxxxxxx>
# Date 1282568348 -3600
# Node ID 0adab5c36ecab8252b6f354a9b6d285d30c94254
# Parent  d6b47ef01193698a7c17d2ef0ab6feaec5eeedf5
Move the handy 'substring' record type into the Zerocheck module.

Signed-off-by: David Scott <dave.scott@xxxxxxxxxxxxx>

diff -r d6b47ef01193 -r 0adab5c36eca stdext/zerocheck.ml
--- a/stdext/zerocheck.ml       Mon Aug 23 13:58:27 2010 +0100
+++ b/stdext/zerocheck.ml       Mon Aug 23 13:59:08 2010 +0100
@@ -25,6 +25,12 @@
 let find_a_nonzero = wrap _find_a_nonzero
 let find_a_zero = wrap _find_a_zero
 
+type substring = {
+       buf: string;
+       offset: int;
+       len: int
+}
+
 let fold_over_nonzeros x len roundup f initial = 
        let rec inner acc offset = 
                if offset = len then acc
@@ -36,6 +42,6 @@
                        | None -> len
                        | Some e -> e in
                        let e = min len (roundup e) in
-                       inner (f acc (s, e - s)) e in
+                       inner (f acc { buf = x; offset = s; len = e - s }) e in
        inner initial 0
 
diff -r d6b47ef01193 -r 0adab5c36eca stdext/zerocheck.mli
--- a/stdext/zerocheck.mli      Mon Aug 23 13:58:27 2010 +0100
+++ b/stdext/zerocheck.mli      Mon Aug 23 13:59:08 2010 +0100
@@ -27,8 +27,14 @@
     strictly the first nonzero. *)
 val find_a_nonzero: string -> int -> int -> int option
 
+type substring = {
+       buf: string;
+       offset: int;
+       len: int
+}
+
 (** [fold_over_nonzeros buf len roundup f initial] folds [f] over all 
     (start, length) pairs of non-zero data in string [buf] up to [len]. 
     The end offset of each pair is rounded up with [roundup] (e.g. to 
     potential block boudaries. *)
-val fold_over_nonzeros: string -> int -> (int -> int) -> ('a -> int * int -> 
'a) -> 'a -> 'a
+val fold_over_nonzeros: string -> int -> (int -> int) -> ('a -> substring -> 
'a) -> 'a -> 'a
 stdext/zerocheck.ml  |  8 +++++++-
 stdext/zerocheck.mli |  8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)


Attachment: xen-api-libs.hg.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-API] [PATCH] add handy substring type, David Scott <=