X-Git-Url: http://git.annexia.org/?p=virt-mem.git;a=blobdiff_plain;f=lib%2Fvirt_mem_utils.ml;fp=lib%2Fvirt_mem_utils.ml;h=a1eab8ffc11366d6ffe4e6a717b2df173b09cdba;hp=0a3b687b145430248ec4512ca56acc0e4b5d8e1c;hb=02eb2bb9cd33f08e542ed22175dcf8388cad5b79;hpb=11e279c9ab78052b78338fcfceb3aa549522de41 diff --git a/lib/virt_mem_utils.ml b/lib/virt_mem_utils.ml index 0a3b687..a1eab8f 100644 --- a/lib/virt_mem_utils.ml +++ b/lib/virt_mem_utils.ml @@ -117,6 +117,16 @@ let pad width str = if n >= width then str else (* if n < width then *) str ^ String.make (width-n) ' ' +(* Truncate an OCaml string at the first ASCII NUL character, ie. as + * if it were a C string. + *) +let truncate_c_string str = + try + let i = String.index str '\000' in + String.sub str 0 i + with + Not_found -> str + (** General binary tree type. Data 'a is stored in the leaves and 'b is stored in the nodes. *) type ('a,'b) binary_tree =