/*
  FlushDevice.c
 
  Applications which need to flush a specific device from memory
  should never do so by requesting a huge memory allocation.
  The code provided here demonstrates the proper way to flush
  a specific device, should it be necessary.

  Copyright (c) 1988 Commodore-Amiga, Inc.
 
  Executables based on this information may be used in software
  for Commodore Amiga computers.  All other rights reserved.
 
  This information is provided "as is"; no warranties are made.
  All use is at your own risk, and no liability or responsibility is assumed.
*/


#include "exec/types.h"
#include "exec/execbase.h"
#include "proto/exec.h"

void FlushDevice(char *);

extern struct ExecBase *SysBase;


void main()
{
	FlushDevice("serial.device");
}


/*
 * Attempts to flush the named device out of memory.
 * If it fails, no status is returned; examination of
 * the problem will reveal that information has no
 * valid use after the Permit().
 */
void FlushDevice(name)
char  *name;
{
struct Device *result;

    Forbid();
    if( result=(struct Device *)FindName(&SysBase->DeviceList,name) )
	{
	printf("RemDeving %s\n",name);
	RemDevice(result);
	}
    Permit();
}
