forked from jlucid/capi
-
Notifications
You must be signed in to change notification settings - Fork 4
/
refcountk.c
36 lines (30 loc) · 785 Bytes
/
refcountk.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* File name: refcountk.c */
#include "common.h"
int main() {
I handle;
I portnumber= 12345;
S hostname= "localhost";
S usernamePassword= "kdb:pass";
K response, a;
// NOTE: connection must be opened before creating K objects
handle= khpu(hostname, portnumber, usernamePassword);
if(!handleOk(handle)) {
m9();
return EXIT_FAILURE;
}
a= ki(5);
printf("ref count of a is %d\n", a->r);
printf("int value of a is %d\n", a->i);
response= k(handle, "{x+3i}", a, (K) 0);
// it is illigal to access a after this call as object has been destroyed
if(isRemoteErr(response)) {
kclose(handle);
m9();
return EXIT_FAILURE;
}
printf("response value is %d\n", response->i);
r0(response);
kclose(handle);
m9();
return EXIT_SUCCESS;
}