I was doing a wrong thing with creating vecs
The old vector was getting dropped and thus free-ing the old underlying slice. I want to use set_len() on Vec to do this
This commit is contained in:
parent
06a5de6e32
commit
518414ffd5
@ -195,9 +195,9 @@ pub fn GetParams(function: LLVMValueRef) -> Vec<LLVMValueRef> {
|
|||||||
let size = CountParams(function);
|
let size = CountParams(function);
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut container = Vec::with_capacity(size);
|
let mut container = Vec::with_capacity(size);
|
||||||
let p = container.as_mut_ptr();
|
container.set_len(size);
|
||||||
core::LLVMGetParams(function, p);
|
core::LLVMGetParams(function, container.as_mut_ptr());
|
||||||
Vec::from_raw_parts(p, size, size)
|
container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,9 +244,9 @@ pub fn GetBasicBlocks(function: LLVMValueRef) -> Vec<LLVMBasicBlockRef> {
|
|||||||
let size = CountBasicBlocks(function);
|
let size = CountBasicBlocks(function);
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut container = Vec::with_capacity(size);
|
let mut container = Vec::with_capacity(size);
|
||||||
let p = container.as_mut_ptr();
|
container.set_len(size);
|
||||||
core::LLVMGetBasicBlocks(function, p);
|
core::LLVMGetBasicBlocks(function, container.as_mut_ptr());
|
||||||
Vec::from_raw_parts(p, size, size)
|
container
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user