summaryrefslogtreecommitdiff
path: root/dev-ml/cairo2/files/cairo2-0.6.1-handle-safe-string.patch
blob: 8571da4ea9fe0eba42e3a2591c1b57baa8c330d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
commit 9881f6c861ccf1150fffd6ccdb8b93181ad14263 (HEAD -> const, origin/const)
Author: Olaf Hering <olaf@aepfle.de>
Date:   Fri Jul 17 15:47:59 2020 +0200

    handle safe-string
    
    String_val() returns 'const char *'.
    caml_named_value returns 'const value *'.
    
    Signed-off-by: Olaf Hering <olaf@aepfle.de>

diff --git a/src/cairo_macros.h b/src/cairo_macros.h
index d952c10..1348b27 100644
--- a/src/cairo_macros.h
+++ b/src/cairo_macros.h
@@ -173,7 +173,7 @@
 
 /* holds the pointer to the Unavailable exception; shared several
    functions. */
-value * caml_cairo_Unavailable = NULL;
+const value * caml_cairo_Unavailable = NULL;
 
 #define RAISE_UNAVAILABLE(name, args ...)                               \
   CAMLexport value caml_##name(args)                                    \
diff --git a/src/cairo_ocaml_types.h b/src/cairo_ocaml_types.h
index b850ae2..267f657 100644
--- a/src/cairo_ocaml_types.h
+++ b/src/cairo_ocaml_types.h
@@ -45,7 +45,7 @@ DEFINE_CUSTOM_OPERATIONS(cairo, cairo_destroy, CAIRO_VAL)
 /* raise [Error] if the status indicates a failure. */
 void caml_cairo_raise_Error(cairo_status_t status)
 {
-  static value * exn = NULL;
+  static const value * exn = NULL;
 
   if (status != CAIRO_STATUS_SUCCESS) {
     if (exn == NULL) {
diff --git a/src/cairo_stubs.c b/src/cairo_stubs.c
index de35aca..597c0bf 100644
--- a/src/cairo_stubs.c
+++ b/src/cairo_stubs.c
@@ -1681,7 +1681,7 @@ static cairo_status_t caml_cairo_output_string
   CAMLlocal2(s, r);
 
   s = caml_alloc_string(length);
-  memmove(String_val(s), data, length);
+  memmove(&Byte(String_val(s), 0), data, length);
   r = caml_callback_exn(* ((value *) fn), s);
   if (Is_exception_result(r))
     CAMLreturn(CAIRO_STATUS_WRITE_ERROR);