mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[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:
parent
9618c5b07c
commit
fd9efc7499
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user