From 518414ffd5abae8f637005c39a68602904bbb5bc Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 16 Jan 2017 00:04:09 -0800 Subject: [PATCH] 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 --- src/llvm_wrap.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/llvm_wrap.rs b/src/llvm_wrap.rs index 148577e..010698f 100644 --- a/src/llvm_wrap.rs +++ b/src/llvm_wrap.rs @@ -195,9 +195,9 @@ pub fn GetParams(function: LLVMValueRef) -> Vec { let size = CountParams(function); unsafe { let mut container = Vec::with_capacity(size); - let p = container.as_mut_ptr(); - core::LLVMGetParams(function, p); - Vec::from_raw_parts(p, size, size) + container.set_len(size); + core::LLVMGetParams(function, container.as_mut_ptr()); + container } } @@ -244,9 +244,9 @@ pub fn GetBasicBlocks(function: LLVMValueRef) -> Vec { let size = CountBasicBlocks(function); unsafe { let mut container = Vec::with_capacity(size); - let p = container.as_mut_ptr(); - core::LLVMGetBasicBlocks(function, p); - Vec::from_raw_parts(p, size, size) + container.set_len(size); + core::LLVMGetBasicBlocks(function, container.as_mut_ptr()); + container } }