Using map in Aerospike's c client

I’m struggling in using as_map. I tried using as_map in the following way in my c++ program:

as_map test_map;
as_string s1;

char * ts1=new char[10];
memset(ts1,0,10);
strncpy(ts1,"hdfc",10);

as_string_init(&s1, ts1, false);

as_string s2;
char * ts2=new char[10];
memset(ts2,0,10);
strncpy(ts2,"5010010",10);

as_string_init(&s2, ts2, false);

as_val* vs1= as_string_toval(&s1);
as_val* vs2=as_string_toval(&s2);

int l_status=as_map_set(map_p,vs1,vs2);

cout<<endl<<"status: "<<l_status<<endl;

But I’m getting segmentation fault when I’m calling ‘as_map_set’. What exactly am I doing wrong? Please help.

Look at examples in the C Client. aerospike-client-c/example.c at master · aerospike/aerospike-client-c · GitHub

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.