From 2d44da33b4f58efce67d45f9f9f7a0ecedb37346 Mon Sep 17 00:00:00 2001 From: Alex Clink Date: Mon, 28 Feb 2022 00:02:04 -0500 Subject: [PATCH] Use out instead of uninitialized/pointer --- src/sprite.cr | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/sprite.cr b/src/sprite.cr index 3d349a9..7cb2b31 100644 --- a/src/sprite.cr +++ b/src/sprite.cr @@ -102,12 +102,7 @@ module PF # Sample a color at an *x* and *y* position def sample(x : Int, y : Int) raw_pixel = peak(x, y) - - r = uninitialized UInt8 - g = uninitialized UInt8 - b = uninitialized UInt8 - - LibSDL.get_rgb(raw_pixel, format, pointerof(r), pointerof(g), pointerof(b)) + LibSDL.get_rgb(raw_pixel, format, out r, out g, out b) Pixel.new(r, g, b) end @@ -120,13 +115,7 @@ module PF def sample(x : Int, y : Int, alpha : Boolean) return sample(x, y) unless alpha raw_pixel = pixel_pointer(x, y).value - - r = uninitialized UInt8 - g = uninitialized UInt8 - b = uninitialized UInt8 - a = uninitialized UInt8 - - LibSDL.get_rgba(raw_pixel, format, pointerof(r), pointerof(g), pointerof(b), pointerof(a)) + LibSDL.get_rgba(raw_pixel, format, out r, out g, out b, out a) Pixel.new(r, g, b, a) end