Skip to content

Commit c7688b8

Browse files
committed
make code more readable by removing ptr.add tricks
1 parent fcf3245 commit c7688b8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/sdl2/video.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1986,13 +1986,17 @@ impl Window {
19861986

19871987
#[doc(alias = "SDL_GetWindowGammaRamp")]
19881988
pub fn gamma_ramp_arrays(&self) -> Result<[[u16; 256]; 3], String> {
1989-
let mut ret = mem::MaybeUninit::<[[u16; 256]; 3]>::uninit();
1990-
let ptr = ret.as_mut_ptr().cast::<u16>();
1989+
let [mut red, mut green, mut blue] = [mem::MaybeUninit::<[u16; 256]>::uninit(); 3];
19911990
let result = unsafe {
1992-
sys::SDL_GetWindowGammaRamp(self.context.raw, ptr, ptr.add(256), ptr.add(512))
1991+
sys::SDL_GetWindowGammaRamp(
1992+
self.context.raw,
1993+
red.as_mut_ptr().cast::<u16>(),
1994+
green.as_mut_ptr().cast::<u16>(),
1995+
blue.as_mut_ptr().cast::<u16>(),
1996+
)
19931997
};
19941998
if result == 0 {
1995-
Ok(unsafe { ret.assume_init() })
1999+
Ok(unsafe { [red.assume_init(), green.assume_init(), blue.assume_init()] })
19962000
} else {
19972001
Err(get_error())
19982002
}

0 commit comments

Comments
 (0)