X-Git-Url: http://git.annexia.org/?p=virt-top.git;a=blobdiff_plain;f=src%2Ftop.ml;h=d4f76972e9215abb417e072614b8e48c99c8f9a4;hp=204f3b68393753c48477410506e1c0bbc43ecd5c;hb=a58c90e04e5b54f8c6a67b09a93cfc33402cf398;hpb=90d14bc151e488972d33eefaac2242d9a6e07578 diff --git a/src/top.ml b/src/top.ml index 204f3b6..d4f7697 100644 --- a/src/top.ml +++ b/src/top.ml @@ -296,17 +296,20 @@ let millisleep n = *) let get_string maxlen = ignore (echo ()); - let str = String.create maxlen in - let ok = getstr str in (* Safe because binding calls getnstr. *) + let str = Bytes.create maxlen in + (* Safe because binding calls getnstr. However the unsafe cast + * to string is required because ocaml-curses needs to be fixed. + *) + let ok = getstr (Obj.magic str) in ignore (noecho ()); if not ok then "" else ( (* Chop at first '\0'. *) try - let i = String.index str '\000' in - String.sub str 0 i + let i = Bytes.index str '\000' in + Bytes.sub_string str 0 i with - Not_found -> str (* it is full maxlen bytes *) + Not_found -> Bytes.to_string str (* it is full maxlen bytes *) ) (* Main loop. *) @@ -319,7 +322,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _, while not !quit do (* Collect stats. *) - let state = collect setup !block_in_bytes in + let state = collect setup in let pcpu_display = if !display_mode = PCPUDisplay then Some (collect_pcpu state) else None in @@ -331,7 +334,7 @@ let rec main_loop ((_, batch_mode, script_mode, csv_enabled, stream_mode, _, _, (* Update CSV file. *) if csv_enabled then - Csv_output.append_csv setup csv_flags state; + Csv_output.append_csv setup csv_flags !block_in_bytes state; (* Append to stream output file. *) if stream_mode then