Skip to content

Commit e36421f

Browse files
committed
wrong
1 parent 9c70c71 commit e36421f

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

crates/byondapi-rs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "byondapi"
3-
version = "0.4.3"
3+
version = "0.4.4"
44
authors = ["tigercat2000 <nick.pilant@gmail.com>"]
55
edition = "2021"
66
description = "Idiomatic Rust bindings for BYONDAPI"

crates/byondapi-rs/src/map.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ pub fn byond_block(corner1: ByondXYZ, corner2: ByondXYZ) -> Result<Vec<ByondValu
3838
}
3939

4040
BUFFER.with_borrow_mut(|buff| -> Result<Vec<ByondValue>, Error> {
41-
let initial_len = buff.capacity() as u32;
4241
let mut len = buff.capacity() as u32;
4342
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
4443
let initial_res = unsafe {
4544
byond().Byond_Block(&corner1.0, &corner2.0, buff.as_mut_ptr().cast(), &mut len)
4645
};
4746
match (initial_res, len) {
4847
(false, 1..) => {
49-
debug_assert!(len > initial_len);
50-
buff.reserve_exact((len - initial_len) as usize);
48+
buff.reserve_exact(len as usize);
5149
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
5250
unsafe {
5351
map_byond_error!(byond().Byond_Block(

crates/byondapi-rs/src/value/functions.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ impl ByondValue {
4242
}
4343

4444
let bytes = BUFFER.with_borrow_mut(|buff| -> Result<Vec<u8>, Error> {
45-
let initial_len = buff.capacity() as u32;
4645
let mut len = buff.capacity() as u32;
4746
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
4847
let initial_res =
4948
unsafe { byond().Byond_ToString(&self.0, buff.as_mut_ptr().cast(), &mut len) };
5049
match (initial_res, len) {
5150
(false, 1..) => {
52-
debug_assert!(len > initial_len);
53-
buff.reserve_exact((len - initial_len) as usize);
51+
buff.reserve_exact(len as usize);
5452
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
5553
unsafe {
5654
map_byond_error!(byond().Byond_ToString(

crates/byondapi-rs/src/value/list.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@ impl ByondValue {
1313
}
1414

1515
BUFFER.with_borrow_mut(|buff| -> Result<Vec<ByondValue>, Error> {
16-
let initial_len = buff.capacity() as u32;
1716
let mut len = buff.capacity() as u32;
1817

1918
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
2019
let initial_res =
2120
unsafe { byond().Byond_ReadList(&self.0, buff.as_mut_ptr().cast(), &mut len) };
2221
match (initial_res, len) {
2322
(false, 1..) => {
24-
debug_assert!(len > initial_len);
25-
buff.reserve_exact((len - initial_len) as usize);
23+
buff.reserve_exact(len as usize);
2624
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
2725
unsafe {
2826
map_byond_error!(byond().Byond_ReadList(
@@ -58,16 +56,14 @@ impl ByondValue {
5856
}
5957

6058
BUFFER.with_borrow_mut(|buff| -> Result<Vec<ByondValue>, Error> {
61-
let initial_len = buff.capacity() as u32;
6259
let mut len = buff.capacity() as u32;
6360

6461
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
6562
let initial_res =
6663
unsafe { byond().Byond_ReadListAssoc(&self.0, buff.as_mut_ptr().cast(), &mut len) };
6764
match (initial_res, len) {
6865
(false, 1..) => {
69-
debug_assert!(len > initial_len);
70-
buff.reserve_exact((len - initial_len) as usize);
66+
buff.reserve_exact(len as usize);
7167
// Safety: buffer capacity is passed to byond, which makes sure it writes in-bound
7268
unsafe {
7369
map_byond_error!(byond().Byond_ReadListAssoc(

0 commit comments

Comments
 (0)