From dd557c8f293dbef3e2e881bcb1a85a7697a1ebbb Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 23 Feb 2025 08:47:17 +0000 Subject: fix memory leak in simulation tests (lol) also, change some vecs into boxed slices, and add RelativeEntityUpdate::new --- azalea-buf/src/read.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'azalea-buf/src/read.rs') diff --git a/azalea-buf/src/read.rs b/azalea-buf/src/read.rs index 324eab87..b1b95f4d 100755 --- a/azalea-buf/src/read.rs +++ b/azalea-buf/src/read.rs @@ -199,6 +199,11 @@ impl AzaleaRead for Vec { Ok(contents) } } +impl AzaleaRead for Box<[T]> { + default fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { + Vec::::azalea_read(buf).map(Vec::into_boxed_slice) + } +} impl AzaleaReadLimited for Vec { fn azalea_read_limited(buf: &mut Cursor<&[u8]>, limit: usize) -> Result { let length = u32::azalea_read_var(buf)? as usize; @@ -216,6 +221,11 @@ impl AzaleaReadLimited for Vec { Ok(contents) } } +impl AzaleaReadLimited for Box<[T]> { + fn azalea_read_limited(buf: &mut Cursor<&[u8]>, limit: usize) -> Result { + Vec::::azalea_read_limited(buf, limit).map(Vec::into_boxed_slice) + } +} impl AzaleaRead for HashMap { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { @@ -297,6 +307,11 @@ impl AzaleaReadVar for Vec { Ok(contents) } } +impl AzaleaReadVar for Box<[T]> { + fn azalea_read_var(buf: &mut Cursor<&[u8]>) -> Result { + Vec::::azalea_read_var(buf).map(Vec::into_boxed_slice) + } +} impl AzaleaRead for i64 { fn azalea_read(buf: &mut Cursor<&[u8]>) -> Result { -- cgit v1.2.3