Skip to content

Commit

Permalink
Merge pull request #79 from zong-zhe/fix-proto-err
Browse files Browse the repository at this point in the history
fix: fix protobuf error
  • Loading branch information
Peefy authored May 15, 2024
2 parents 0266ccc + de8f382 commit 79d8bef
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use std::ffi::{CStr, CString};

pub use kclvm_api::gpyrpc::*;
use kclvm_api::service::capi::{kclvm_service_call, kclvm_service_new};
use kclvm_api::service::capi::{kclvm_service_call_with_length, kclvm_service_new};
use kclvm_api::service::service_impl::KclvmServiceImpl;

use anyhow::Result;
Expand All @@ -41,7 +41,8 @@ pub fn call<'a>(name: &'a [u8], args: &'a [u8]) -> Result<&'a [u8]> {
let args = CString::new(args)?;
let call = CString::new(name)?;
let serv = kclvm_service_new(0);
kclvm_service_call(serv, call.as_ptr(), args.as_ptr())
let mut result_len: usize = 0;
kclvm_service_call_with_length(serv, call.as_ptr(), args.as_ptr(), &mut result_len)
};
let result = unsafe { CStr::from_ptr(result_ptr) };
Ok(result.to_bytes())
Expand Down

0 comments on commit 79d8bef

Please sign in to comment.