[MATLAB] Fixed a problem with string length

Previously the buffer length does not account for
the null terminator, which causes the string returned
from Clib to miss the last character.

The correct error code is also implemented. The
previous code will incorrectly throw an exception
when the string is a single character.
This commit is contained in:
ssun30 2025-02-12 20:33:49 -05:00
parent 9618c5b07c
commit fd9efc7499

View File

@ -4,7 +4,7 @@ function output = ctString(funcName, varargin)
err1 = -1;
buflen = calllib(ctLib, funcName, varargin{:}, 0, '');
buflen = calllib(ctLib, funcName, varargin{:}, 0, '') + 1;
if buflen > 0
aa = char(ones(1, buflen));
@ -25,7 +25,7 @@ function output = ctString(funcName, varargin)
error('Cantera:ctError', ctGetErr);
end
if iok == -err1
if iok == err1
error('Cantera:ctError', ctGetErr);
end