question

Upvote
Accepted
100 6 6 7

does rssl*ToString add 0 in the end of returned string in RsslBuffer.data

Does rssl*ToString add 0 in the end of returned string in RsslBuffer.data so it's a proper C string? API does not mentioned that. Want to double check here.

elektronelektron-sdkrrteta-apielektron-transport-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
1.2k 23 31 44

Some do, some do not, it is not documented in the reference guide. Some can only be inferred from the example usage.

One function returning a C String in a RsslBuffer:

rsslDateTimeToString(&fidDateTimeBuf, RSSL_DT_DATETIME, &fidDateTimeValue);
printf("%s\n", fidDateTimeBuf.data);

Another returning only a buffer:

fidStateBuf.data = (char*)alloca(stateBufLen);
fidStateBuf.length = stateBufLen;
rsslStateToString(&fidStateBuf, &fidStateValue);
printf("%.*s\n", fidStateBuf.length, fidStateBuf.data);

Also some API completely ignore the apparent RsslBuffer standard signature and do return a C-String.

const char* rsslQosTimelinessToString(RsslUInt8 value)
{
    switch (value)
    {
    case RSSL_QOS_TIME_UNSPECIFIED:     return "Unspecified";
    case RSSL_QOS_TIME_REALTIME:        return "Realtime";
    case RSSL_QOS_TIME_DELAYED_UNKNOWN: return "DelayedByUnknown";
    case RSSL_QOS_TIME_DELAYED:         return "DelayedByTimeInfo";
    default:                            return "Unknown QosTimeliness";
    }
}
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
11.3k 25 9 14

I have tried to debug the rsslStateToString function. The RsslBuffer.data always contains the null termination, even though the example code uses the RsslBuffer.length to print string.

I think rssl*ToString functions should generally add the 0 at the end of string of the rsslBuffer.data.


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.