Skip to content

Commit 9110313

Browse files
inklesspensdroege
authored andcommitted
cairo: write-to-stream callbacks should accept const pointers to data
This is in line with the [corresponding C types](https://www.cairographics.org/manual/cairo-PNG-Support.html#cairo-write-func-t); they don't need to mutate this data. Closes #1771.
1 parent 9e9fe41 commit 9110313

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

cairo/src/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ struct MutableCallbackEnvironment {
200200
// so code outside of the `catch_unwind` call must never panic.
201201
extern "C" fn write_callback<W: io::Write + 'static>(
202202
env: *mut c_void,
203-
data: *mut c_uchar,
203+
data: *const c_uchar,
204204
length: c_uint,
205205
) -> ffi::cairo_status_t {
206206
// This is consistent with the type of `env` in `Surface::_for_stream`.

cairo/src/surface_png.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct WriteEnv<'a, W: 'a + Write> {
5757

5858
unsafe extern "C" fn write_func<W: Write>(
5959
closure: *mut c_void,
60-
data: *mut u8,
60+
data: *const u8,
6161
len: c_uint,
6262
) -> crate::ffi::cairo_status_t {
6363
let write_env: &mut WriteEnv<W> = &mut *(closure as *mut WriteEnv<W>);

cairo/sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub type cairo_destroy_func_t = Option<unsafe extern "C" fn(*mut c_void)>;
262262
pub type cairo_read_func_t =
263263
Option<unsafe extern "C" fn(*mut c_void, *mut c_uchar, c_uint) -> cairo_status_t>;
264264
pub type cairo_write_func_t =
265-
Option<unsafe extern "C" fn(*mut c_void, *mut c_uchar, c_uint) -> cairo_status_t>;
265+
Option<unsafe extern "C" fn(*mut c_void, *const c_uchar, c_uint) -> cairo_status_t>;
266266

267267
#[cfg(feature = "freetype")]
268268
#[cfg_attr(docsrs, doc(cfg(feature = "freetype")))]

0 commit comments

Comments
 (0)