0

ER_BUS_NOT_NUL_TERMINATED and duplicate value.

asked 2014-12-11 02:33:25 -0800

Bhagwatks gravatar image

updated 2014-12-11 09:11:00 -0800

georgen gravatar image

ER_BUS_NOT_NUL_TERMINATED is comming when I am setting

input[i].Set("(s)","string");
outArg.Set("a(s)",num,input)

and also getting duplicate value when

outArg.Set("as",num,array);

outArg.get("as", &num,&member);
member.Get("s",&str); doing like this .
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-12-11 09:56:17 -0800

georgen gravatar image

updated 2014-12-11 10:35:12 -0800

I I suspect you are not treating member as an array so you always get the first elements.

it should be something like this:

member[i].Get("s", &str);

where i is the next element.

Example code showing setting and getting an array of structs:

//Setting an array of structs
MsgArg inputArg[5];
status = inputArg[0].Set("(s)", "Hello");
if(ER_OK != status ) {
    printf("unable to set inputArg[0] status = %s\n", QCC_StatusText(status));
}
status = inputArg[1].Set("(s)", "to");
if(ER_OK != status ) {
    printf("unable to set inputArg[1] status = %s\n", QCC_StatusText(status));
}
status = inputArg[2].Set("(s)", "all");
if(ER_OK != status ) {
    printf("unable to set inputArg[2] status = %s\n", QCC_StatusText(status));
}
status = inputArg[3].Set("(s)", "my");
if(ER_OK != status ) {
    printf("unable to set inputArg[3] status = %s\n", QCC_StatusText(status));
}
status = inputArg[4].Set("(s)", "friends");
if(ER_OK != status ) {
    printf("unable to set inputArg[4] status = %s\n", QCC_StatusText(status));
}

MsgArg outArg;
status = outArg.Set("a(s)", 5, inputArg);
if(ER_OK != status ) {
    printf("unable to set outArg status = %s\n", QCC_StatusText(status));
}

//Getting an array of structs
MsgArg* myOutArg;
size_t  myOutArgNum;
status = outArg.Get("a(s)", &myOutArgNum, &myOutArg);
if(ER_OK != status ) {
    printf("unable to get myOutArg status = %s\n", QCC_StatusText(status));
}
if(5 != myOutArgNum) {
    printf("size of myOutArgNum should be 5 actual size %ul\n", myOutArgNum);
}

const char* outStr[5];
for (size_t i = 0; i < myOutArgNum && i < 5; ++i) {
    status = myOutArg[i].Get("(s)", &outStr[i]);
    if(ER_OK != status ) {
        printf("unable to get struct from myOutArg status = %s\n", QCC_StatusText(status));
    }
}

for (size_t i = 0; i < 5; ++i) {
    printf("%s ", outStr[i]);
}
printf("\n");

Example using an array of strings this is very similar to the array of structs:

//Setting an array of strings
const char* inputStrs[] = {"Hello", "to", "all", "my", "friends"};
MsgArg outArg;
status = outArg.Set("as", 5, inputStrs);
if(ER_OK != status ) {
    printf("unable to set outArg status = %s\n", QCC_StatusText(status));
}

//Getting an array of structs
MsgArg* myOutArg;
size_t  myOutArgNum;
status = outArg.Get("as", &myOutArgNum, &myOutArg);
if(ER_OK != status ) {
    printf("unable to get myOutArg status = %s\n", QCC_StatusText(status));
}
if(5 != myOutArgNum) {
    printf("size of myOutArgNum should be 5 actual size %ul\n", myOutArgNum);
}

const char* outStr[5];
for (size_t i = 0; i < myOutArgNum && i < 5; ++i) {
    status = myOutArg[i].Get("s", &outStr[i]);
    if(ER_OK != status ) {
        printf("unable to get struct from myOutArg status = %s\n", QCC_StatusText(status));
    }
}

for (size_t i = 0; i < 5; ++i) {
    printf("%s ", outStr[i]);
}
printf("\n");
edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-12-11 02:33:25 -0800

Seen: 82 times

Last updated: Dec 11 '14