Function kdb_c_api::increment_reference_count[][src]

pub fn increment_reference_count(qobject: K) -> K
Expand description

Increment reference count of the q object. Increment must be done when you passed arguments to Rust function and intends to return it to q side or when you pass some K objects to k function and intend to use the argument after the call. See details on the reference page.

Example

use kdb_c_api::*;
 
fn eat(apple: K){
  println!("おいしい!");
}
 
#[no_mangle]
pub extern "C" fn satisfy_5000_men(apple: K) -> K{
  for _ in 0..10{
    eat(apple);
  }
  unsafe{native::k(0, str_to_S!("eat"), increment_reference_count(apple), KNULL);}
  increment_reference_count(apple)  
}
q)eat:{[apple] show "Collect the clutter of apples!";}
q)bread_is_a_sermon: libc_api_examples 2: (`satisfy_5000_men; 1);
q)bread_is_a_sermon[`green_apple]
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
おいしい!
"Collect the clutter of apples!"