SS_OPTION_CALL_TERMINATE_ON_EXIT

Force call to mdlTerminate

Description

Guarantees the Simulink® engine calls the S-function's mdlTerminate method before destroying a block that references the S-function. Calling mdlTerminate allows your S-function to clean up after itself, for example, by freeing memory it allocated during a simulation. The engine destroys an S-function block under the following circumstances.

  1. A simulation ends either normally or as a result of invoking ssSetErrorStatus.

  2. A user deletes the block.

  3. The engine eliminates the block as part of a block reduction optimization (see Block reduction).

If this option is not set, the engine calls your S-function's mdlTerminate method only if the mdlStart method of at least one block in the model containing the S-function executed without error.

Example

See the S-function sfun_runtime3.csfun_runtime3.c for an example.

See Also

mdlTerminate

Was this topic helpful?