Skip to content

Commit

Permalink
Avoid c.x pointing to external array
Browse files Browse the repository at this point in the history
  • Loading branch information
CasBex committed Aug 22, 2023
1 parent a895080 commit 71fd194
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/FMI2/c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1626,7 +1626,7 @@ function fmi2SetContinuousStates(c::FMU2Component,

if track
if status == fmi2StatusOK
isnothing(c.x) ? (c.x = x;) : copyto!(c.x, x)
isnothing(c.x) ? (c.x = copy(x);) : copyto!(c.x, x)

FMICore.invalidate!(c.A)
FMICore.invalidate!(c.C)
Expand Down
4 changes: 2 additions & 2 deletions src/FMI2/int.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ function fmi2SetContinuousStates(c::FMU2Component, x::AbstractArray{fmi2Real}; k
nx = Csize_t(length(x))
status = fmi2SetContinuousStates(c, x, nx; kwargs...)
if status == fmi2StatusOK
c.x = x
isnothing(c.x) ? (c.x = copy(x);) : copyto!(c.x, x)
end
return status
end
Expand Down Expand Up @@ -1357,4 +1357,4 @@ function fmi2GetStatus(c::FMU2Component, s::fmi2StatusKind)
end

status, value[1]
end
end

0 comments on commit 71fd194

Please sign in to comment.