pub unsafe extern "C" fn jk(list: *mut K, value: K) -> KExpand description
Add a q object to a q compound list.
Returns a pointer to the (potentially reallocated) K object.
§Example
#[macro_use]
extern crate kdbplus;
use kdbplus::api::*;
use kdbplus::api::native::*;
#[no_mangle]
pub extern "C" fn create_compound_list(_: K) -> K{
unsafe{
let mut list=knk(0);
jk(&mut list, ks(str_to_S!("1st")));
jk(&mut list, ki(2));
jk(&mut list, kpn(str_to_S!("3rd"), "3rd".chars().count() as i64));
list
}
}q)ranks: `libc_api_examples 2: (`create_compound_list; 1);
q)ranks[]
`1st
2i
"3rd"§Note
In this example we did not allocate an array as knk(0) to use jk. As knk initializes the
internal list size n with its argument, preallocating memory with knk and then using jk will crash.
If you want to allocate a memory in advance, you can substitute a value after converting
the q list object into a slice with as_mut_slice.