Obtaining a String of a Given Length
Sometimes you need to make sure that the string in an IDL_STRING descriptor has a specific length. The IDL_StrEnsureLength() function can be used in this case:
where:
s
A pointer to the IDL_STRING that will have its length checked.
n
The number of characters the string must be able to contain, not including the terminating null character.
If the IDL_STRING passed already has enough room for the specified number of characters, it is not re-allocated. Otherwise, the existing string is freed and a new string of sufficient length is allocated. In either case, the slen field of the IDL_STRING will be set to the requested length.
If a new dynamic string is allocated, it will contain garbage values because IDL_StrEnsureLength() only allocates memory of the specified size, it does not copy a value into it. Therefore, the calling routine must copy a null-terminated string into the new dynamic string.