Fix RocList memory leak

Also, reduces the number of elements in the quicksort example to make it
run better with valgrind.
This commit is contained in:
Brendan Hansknecht 2020-10-11 19:00:35 -07:00
parent a092a7642a
commit 97c23557c7
2 changed files with 3 additions and 3 deletions

View file

@ -6,7 +6,7 @@ extern "C" {
fn quicksort(list: RocList<i64>) -> RocList<i64>; fn quicksort(list: RocList<i64>) -> RocList<i64>;
} }
const NUM_NUMS: usize = 1_000_000; const NUM_NUMS: usize = 10_000;
#[no_mangle] #[no_mangle]
pub fn rust_main() -> isize { pub fn rust_main() -> isize {
@ -14,7 +14,7 @@ pub fn rust_main() -> isize {
let mut nums = Vec::with_capacity(NUM_NUMS); let mut nums = Vec::with_capacity(NUM_NUMS);
for index in 0..nums.capacity() { for index in 0..nums.capacity() {
let num = index as i64 % 12345; let num = index as i64 % 123;
nums.push(num); nums.push(num);
} }

View file

@ -71,7 +71,7 @@ impl<T> RocList<T> {
let value = *self.get_storage_ptr(); let value = *self.get_storage_ptr();
// NOTE doesn't work with elements of 16 or more bytes // NOTE doesn't work with elements of 16 or more bytes
match usize::cmp(&0, &value) { match isize::cmp(&(value as isize), &0) {
Equal => Some(Storage::ReadOnly), Equal => Some(Storage::ReadOnly),
Less => Some(Storage::Refcounted(value)), Less => Some(Storage::Refcounted(value)),
Greater => Some(Storage::Capacity(value)), Greater => Some(Storage::Capacity(value)),