From: Stephane Glondu Date: Tue, 6 Aug 2024 13:33:52 +0200 Subject: Fix compilation with OCaml 5.2.0 --- src/cairo_png.ml | 2 +- src/ml_cairo.c | 2 +- src/ml_cairo_ft.c | 8 ++++---- src/ml_cairo_status.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cairo_png.ml b/src/cairo_png.ml index c4a7024..bb6b368 100644 --- a/src/cairo_png.ml +++ b/src/cairo_png.ml @@ -13,7 +13,7 @@ let image_surface_create_from_channel ic = image_surface_create_from_stream_unsafe (fun s n -> for i = 0 to n - 1 do - String.unsafe_set s i (input_char ic) + Bytes.unsafe_set s i (input_char ic) done) let image_surface_create_from_file fname = diff --git a/src/ml_cairo.c b/src/ml_cairo.c index 7f50a1d..5ac6d82 100644 --- a/src/ml_cairo.c +++ b/src/ml_cairo.c @@ -540,7 +540,7 @@ ml_cairo_write_func (void *closure, const unsigned char *data, unsigned int leng { value s, res, *c = closure; s = caml_alloc_string (length); - memcpy (String_val (s), data, length); + memcpy (Bytes_val (s), data, length); res = caml_callback_exn (Field (*c, 0), s); if (Is_exception_result (res)) { diff --git a/src/ml_cairo_ft.c b/src/ml_cairo_ft.c index 4bc1607..308310f 100644 --- a/src/ml_cairo_ft.c +++ b/src/ml_cairo_ft.c @@ -31,7 +31,7 @@ ml_raise_FT_Error (FT_Error err) } static value -Val_ptr (void *p) +ml_FT_Val_ptr (void *p) { value v = caml_alloc_small (1, Abstract_tag); Field (v, 0) = Val_bp (p); @@ -45,7 +45,7 @@ ml_FT_Init_FreeType (value unit) { FT_Library lib; ml_raise_FT_Error (FT_Init_FreeType (&lib)); - return Val_ptr (lib); + return ml_FT_Val_ptr (lib); } CAMLprim value @@ -65,7 +65,7 @@ ml_FT_New_Face (value lib, value o_index, value path) ml_raise_FT_Error (FT_New_Face (FT_Library_val (lib), String_val (path), index, &face)); - return Val_ptr (face); + return ml_FT_Val_ptr (face); } CAMLprim value @@ -114,7 +114,7 @@ ml_FcNameUnparse (value patt) /* cairo Fontconfig/Freetype font backend */ wML_1 (cairo_ft_font_face_create_for_pattern, FcPattern_val, Val_cairo_font_face_t) wML_2 (cairo_ft_font_face_create_for_ft_face, FT_Face_val, Int_val, Val_cairo_font_face_t) -wML_1 (cairo_ft_scaled_font_lock_face, cairo_scaled_font_t_val, Val_ptr) +wML_1 (cairo_ft_scaled_font_lock_face, cairo_scaled_font_t_val, ml_FT_Val_ptr) wML_1 (cairo_ft_scaled_font_unlock_face, cairo_scaled_font_t_val, Unit) #else diff --git a/src/ml_cairo_status.c b/src/ml_cairo_status.c index 1863ed5..4939d59 100644 --- a/src/ml_cairo_status.c +++ b/src/ml_cairo_status.c @@ -20,7 +20,7 @@ wML_1 (cairo_status_to_string, Int_val, caml_copy_string) void ml_cairo_treat_status (cairo_status_t status) { - static value *cairo_exn; + static const value *cairo_exn; assert (status != CAIRO_STATUS_SUCCESS);