function unsetenv(name)
%MATLAB Code Generation Library Function

% Limitations
% 1. Not supported in parallel region.

%    Copyright 2023 The MathWorks, Inc.
%#codegen

coder.extrinsic('unsetenv')
if coder.internal.runs_in_matlab()
    unsetenv(name);
    return
end

narginchk(1, 1);
coder.internal.errorIf(coder.internal.isInParallelRegion(), ...
    'Coder:toolbox:SetEnvPARFOR');

nameIsString = coder.internal.isTextRow(name);

if coder.internal.isAmbiguousTypes
    return
end

coder.internal.assert(nameIsString, 'MATLAB:string');

if strlength(name) == 0
    return;
end

coder.internal.errorIf(contains(name, '='), 'MATLAB:setenv:IllegalNameInvalidCharacter');
coder.internal.errorIf(strlength(name) > 32766, 'MATLAB:setenv:IllegalNameTooLong');

coder.internal.portableEnv.unsetenvImpl(name);

