VST String Lengths and Null Terminator

I noticed that the Juce VST wrapper assumes parameter names and other similar strings include the null terminator when defining the length. But the VST spec seems to assume the length does not include the null. A consequence of this is when my plug-in returns a string that is the max number of characters the last character gets deleted. I could change my plug-in to assume the length returned includes the null, but I don’t think that makes sense given the VST spec and sometimes I really want the extra character for long names.

Here’s the relevant text in aeffect.h:

//-------------------------------------------------------------------------------------------------------
/** String length limits (in characters excl. 0 byte) */
//-------------------------------------------------------------------------------------------------------
enum VstStringConstants
{
//-------------------------------------------------------------------------------------------------------
kVstMaxProgNameLen = 24, ///< used for #effGetProgramName, #effSetProgramName, #effGetProgramNameIndexed
kVstMaxParamStrLen = 8, ///< used for #effGetParamLabel, #effGetParamDisplay, #effGetParamName
kVstMaxVendorStrLen = 64, ///< used for #effGetVendorString, #audioMasterGetVendorString
kVstMaxProductStrLen = 64, ///< used for #effGetProductString, #audioMasterGetProductString
kVstMaxEffectNameLen = 32 ///< used for #effGetEffectName
//-------------------------------------------------------------------------------------------------------
};

//-------------------------------------------------------------------------------------------------------
/** String copy taking care of null terminator. /
//-------------------------------------------------------------------------------------------------------
inline char
vst_strncpy (char* dst, const char* src, size_t maxLen)
{
char* result = strncpy (dst, src, maxLen);
dst[maxLen] = 0;
return result;
}

I propose changing the VST wrapper to add 1 to the length when doing copyToUTF8 like this example:

void getParameterName (VstInt32 index, char* text) override
{
    if (filter != nullptr)
    {
        jassert (isPositiveAndBelow (index, filter->getNumParameters()));
        filter->getParameterName (index, 16).copyToUTF8 (text, 16+1); // length should technically be kVstMaxParamStrLen, which is 8, but hosts will normally allow a bit more.
    }
}

What do you think?

-Chris

Seems like a valid request. See latest develop tip.

Looks good. Thanks.

I do not understand this…
Why does the example use 16 for the length of the parameter name, if kVstMaxParamStrLen is defined to be 8?