Close a flash memory simulator instance and release its resources.
MCO_RET mco_flashsim_close(
/*IN*/ mco_flashsim_h fs
);
fs
mco_flashsim_open().This function decrements the reference count of the flash simulator instance. When the reference count reaches zero, the simulator’s internal state is destroyed and the underlying memory device is released.
The flash simulator supports shared access: multiple calls to
mco_flashsim_open()with the same memory device return the same instance with an incremented reference count. Therefore, eachmco_flashsim_open()must be matched with a correspondingmco_flashsim_close().If the simulator was configured in file-based mode (
file_based = MCO_YES), any pending data is already persisted to the image file during normal operations; this function does not perform an explicit flush.After closing, the memory device may be reused or freed by the application.
MCO_S_OK
MCO_E_INVALID_HANDLE
mco_device_t dev;
mco_flashsim_params_t params = {0};
mco_flashsim_h fs;
// ... initialize params and allocate dev ...
MCO_RET rc = mco_flashsim_open(&dev, ¶ms, &fs);
if (rc == MCO_S_OK) {
// Use simulator...
// Close when done
mco_flashsim_close(fs);
free(dev.dev.conv.ptr); // if allocated on heap
}