Changed how strings are passed between Matlab and Clib

This commit is contained in:
ssun30 2022-08-12 13:44:19 -04:00 committed by Ray Speth
parent e5a77854c2
commit ba4d10fde9
2 changed files with 11 additions and 10 deletions

View File

@ -824,11 +824,13 @@ classdef ThermoPhase < handle
%
buflen = calllib(ct, 'thermo_getEosType', tp.tpID, 0, '');
if buflen > 0
aa = char(zeros(1, buflen));
[~, aa] = calllib(ct, 'thermo_getEosType', ...
tp.tpID, buflen, aa);
aa = char([zeros(1, buflen, 'int8')]);
ptr = libpointer('cstring', aa);
[~, bb] = calllib(ct, 'thermo_getEosType', ...
tp.tpID, buflen, ptr);
e = bb;
clear aa bb ptr;
end
e = aa;
end
function v = isIdealGas(tp)
@ -1343,9 +1345,6 @@ classdef ThermoPhase < handle
% :param temperature:
% Temperature. Units: K
%
if temperature <= 0
error('The temperature must be positive');
end
calllib(ct, 'thermo_setTemperature', tp.tpID, temperature);
end

View File

@ -4,9 +4,11 @@ function e = geterr()
checklib;
try
buflen = calllib(ct, 'ct_getCanteraError', 0, '');
aa = char(zeros(1, buflen));
[~, aa] = calllib(ct, 'ct_getCanteraError', buflen, aa);
e = aa;
aa = char([zeros(1, buflen, 'int8')]);
ptr = libpointer('cstring', aa);
[~, bb] = calllib(ct, 'ct_getCanteraError', buflen, ptr);
e = bb;
clear aa bb ptr
catch ME
e = getReport(ME);
end