Skip to content

Commit

Permalink
Allocate memory for vararray as needed in Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch committed Oct 20, 2023
1 parent 92e5c65 commit 46b7966
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/xdrgen/generators/rust/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/block_comments.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/const.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/enum.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/nesting.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/optional.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/struct.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/test.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down
2 changes: 1 addition & 1 deletion spec/output/generator_spec_rust/union.x/MyXDR.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,7 @@ impl<T: ReadXdr, const MAX: u32> ReadXdr for VecM<T, MAX> {
return Err(Error::LengthExceedsMax);
}

let mut vec = Vec::with_capacity(len as usize);
let mut vec = Vec::new(len as usize);
for _ in 0..len {
let t = T::read_xdr(r)?;
vec.push(t);
Expand Down

0 comments on commit 46b7966

Please sign in to comment.