Skip to main content

r1

Function r1 

Source
pub unsafe extern "C" fn r1(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 parameter after the call. See details on the reference page.

ยงExample

#[macro_use]
extern crate kdbplus;
use kdbplus::api::*;
use kdbplus::api::native::*;

#[no_mangle]
pub extern "C" fn pass_through_cave(pedestrian: K) -> K{
  let item=unsafe{k(0, str_to_S!("get_item1"), r1(pedestrian), KNULL)};
  println!("What do you see, son of man?: {}", item.get_str().expect("oh no"));
  unsafe{r0(item)};
  let item=unsafe{k(0, str_to_S!("get_item2"), r1(pedestrian), KNULL)};
  println!("What do you see, son of man?: {}", item.get_str().expect("oh no"));
  unsafe{
    r0(item);
    r1(pedestrian)
  }
}
q)get_item1:{[man] "a basket of summer fruit"};
q)get_item2:{[man] "boiling pot, facing away from the north"}
q).capi.pass_through_cave[`son_of_man]
What do you see, son of man?: a basket of summer fruit
What do you see, son of man?: boiling pot, facing away from the north
`son_of_man