Compare commits

...

3 commits
v3.18 ... main

Author SHA1 Message Date
Simon Cruanes
aba4c79625 fix CCString: clear buffer after use in sprintf
Some checks failed
format / format (push) Has been cancelled
Build and Test / build (push) Has been cancelled
fix #487
2026-03-02 17:36:31 -05:00
Simon Cruanes
08e8fd3d54 regression test for #487 2026-03-02 17:36:02 -05:00
Simon Cruanes
bc9f361e56
forgot to format
Some checks failed
format / format (push) Has been cancelled
Build and Test / build (push) Has been cancelled
2026-02-14 21:08:29 -05:00
3 changed files with 17 additions and 9 deletions

View file

@ -398,7 +398,10 @@ let sprintf_ c format =
Format.kfprintf Format.kfprintf
(fun _fmt -> (fun _fmt ->
Format.pp_print_flush fmt (); Format.pp_print_flush fmt ();
Buffer.contents buf) let s = Buffer.contents buf in
Buffer.reset buf;
(* in case of reuse *)
s)
fmt format fmt format
let with_color_ksf ~f s fmt = let with_color_ksf ~f s fmt =

View file

@ -410,4 +410,7 @@ q
;; ;;
t @@ fun () -> "ab" < "abc";; t @@ fun () -> "ab" < "abc";;
t @@ fun () -> "123" < "14" t @@ fun () -> "123" < "14";;
eq ~printer:Fun.id "a,b,c,d,e,f,g,"
(flat_map (CCFormat.sprintf "%c,") "abcdefg")

View file

@ -266,13 +266,15 @@ module Op = struct
list_small gen_x >|= fun l -> list_small gen_x >|= fun l ->
Append l, size + List.length l ); Append l, size + List.length l );
]; ];
(if size < 10_000 then [ (if size < 10_000 then
(* flat map can explode, only do it if list isn't too big *) [
( 1, (* flat map can explode, only do it if list isn't too big *)
list_size (0 -- 5) gen_x >|= fun l -> ( 1,
Flat_map l, size * (1 + List.length l) ); list_size (0 -- 5) gen_x >|= fun l ->
] else []) Flat_map l, size * (1 + List.length l) );
; ]
else
[]);
] ]
in in