home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / Devcon_Extras / Tech_Articles / Flushing_Devices < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.2 KB  |  53 lines

  1. /*
  2.   FlushDevice.c
  3.  
  4.   Applications which need to flush a specific device from memory
  5.   should never do so by requesting a huge memory allocation.
  6.   The code provided here demonstrates the proper way to flush
  7.   a specific device, should it be necessary.
  8.  
  9.   Copyright (c) 1988 Commodore-Amiga, Inc.
  10.  
  11.   Executables based on this information may be used in software
  12.   for Commodore Amiga computers.  All other rights reserved.
  13.  
  14.   This information is provided "as is"; no warranties are made.
  15.   All use is at your own risk, and no liability or responsibility is assumed.
  16. */
  17.  
  18.  
  19. #include "exec/types.h"
  20. #include "exec/execbase.h"
  21. #include "proto/exec.h"
  22.  
  23. void FlushDevice(char *);
  24.  
  25. extern struct ExecBase *SysBase;
  26.  
  27.  
  28. void main()
  29. {
  30.     FlushDevice("serial.device");
  31. }
  32.  
  33.  
  34. /*
  35.  * Attempts to flush the named device out of memory.
  36.  * If it fails, no status is returned; examination of
  37.  * the problem will reveal that information has no
  38.  * valid use after the Permit().
  39.  */
  40. void FlushDevice(name)
  41. char  *name;
  42. {
  43. struct Device *result;
  44.  
  45.     Forbid();
  46.     if( result=(struct Device *)FindName(&SysBase->DeviceList,name) )
  47.     {
  48.     printf("RemDeving %s\n",name);
  49.     RemDevice(result);
  50.     }
  51.     Permit();
  52. }
  53.