/* If in RAM: Free the mock buffer If in disk: unmap the flash file from RAM, close the file, and if configured to do so, delete the file.  */
void flash_mock_cleanup_native(bool flash_in_ram, int flash_fd, uint8_t *mock_flash, unsigned int size, const char *flash_file_path, bool flash_rm_at_exit)
/* If in RAM: Free the mock buffer If in disk: unmap the flash file from RAM, close the file, and if configured to do so, delete the file.  */
void flash_mock_cleanup_native(bool flash_in_ram, int flash_fd, uint8_t *mock_flash, unsigned int size, const char *flash_file_path, bool flash_rm_at_exit)
{
	if (flash_in_ram == true) {
		if (mock_flash != NULL) {
			free(mock_flash);
		}
		return;
	}
	if ((mock_flash != MAP_FAILED) && (mock_flash != NULL)) {
		munmap(mock_flash, size);
	}
	if (flash_fd != -1) {
		close(flash_fd);
	}
	if ((flash_rm_at_exit == true) && (flash_file_path != NULL)) {
		(void) remove(flash_file_path);
	}
}