Skip to content

Commit

Permalink
[IRCore] fix a memory leak bug in ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
BingqingLyu committed Nov 13, 2023
1 parent d386676 commit 316db99
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions interactive_engine/executor/ir/core/src/plan/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,33 +529,32 @@ impl From<FfiKeyType> for KeyType {
}
}

/// Query prop_name by given prop_id
/// Query entity/relation/property name by given id
#[no_mangle]
pub extern "C" fn get_key_name(key_id: i32, key_type: FfiKeyType) -> FfiResult {
use super::meta::STORE_META;
if let Ok(meta) = STORE_META.read() {
if let Some(schema) = &meta.schema {
let key_name = match key_type {
FfiKeyType::Entity => schema
.get_entity_name(key_id)
.ok_or(FfiResult::new(
FfiKeyType::Entity => schema.get_entity_name(key_id).ok_or_else(|| {
FfiResult::new(
ResultCode::TableNotExistError,
format!("entity label_id {:?} is not found", key_id),
)),
FfiKeyType::Relation => schema
.get_relation_name(key_id)
.ok_or(FfiResult::new(
)
}),
FfiKeyType::Relation => schema.get_relation_name(key_id).ok_or_else(|| {
FfiResult::new(
ResultCode::TableNotExistError,
format!("relation label_id {:?} is not found", key_id),
)),
FfiKeyType::Column => schema
.get_column_name(key_id)
.ok_or(FfiResult::new(
)
}),
FfiKeyType::Column => schema.get_column_name(key_id).ok_or_else(|| {
FfiResult::new(
ResultCode::ColumnNotExistError,
format!("prop_id {:?} is not found", key_id),
)),
)
}),
};

match key_name {
Ok(key_name) => {
let key_name_cstr = string_to_cstr(key_name.clone());
Expand Down Expand Up @@ -1025,6 +1024,11 @@ mod params {

result
}

#[no_mangle]
pub extern "C" fn destroy_query_params(ptr: *const c_void) {
destroy_ptr::<pb::QueryParams>(ptr)
}
}

mod project {
Expand Down

0 comments on commit 316db99

Please sign in to comment.