home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / freedosobject.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  2.3 KB  |  107 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: freedosobject.c,v 1.6 1997/01/27 00:36:21 ldp Exp $
  4.     $Log: freedosobject.c,v $
  5.     Revision 1.6  1997/01/27 00:36:21  ldp
  6.     Polish
  7.  
  8.     Revision 1.5  1996/12/09 13:53:29  aros
  9.     Added empty templates for all missing functions
  10.  
  11.     Moved #include's into first column
  12.  
  13.     Revision 1.4  1996/10/24 15:50:30  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.3  1996/08/13 13:52:47  digulla
  17.     Replaced <dos/dosextens.h> by "dos_intern.h" or added "dos_intern.h"
  18.     Replaced AROS_LA by AROS_LHA
  19.  
  20.     Revision 1.2  1996/08/01 17:40:52  digulla
  21.     Added standard header for all files
  22.  
  23.     Desc:
  24.     Lang: english
  25. */
  26. #include <exec/memory.h>
  27. #include <proto/exec.h>
  28. #include <dos/exall.h>
  29. #include "dos_intern.h"
  30.  
  31. /*****************************************************************************
  32.  
  33.     NAME */
  34. #include <proto/dos.h>
  35.  
  36.     AROS_LH2(void, FreeDosObject,
  37.  
  38. /*  SYNOPSIS */
  39.     AROS_LHA(ULONG, type, D1),
  40.     AROS_LHA(APTR,  ptr,  D2),
  41.  
  42. /*  LOCATION */
  43.     struct DosLibrary *, DOSBase, 39, Dos)
  44.  
  45. /*  FUNCTION
  46.     Frees an object allocated with AllocDosObject.
  47.  
  48.     INPUTS
  49.     type - object type. The same parameter as given to AllocDosObject().
  50.     ptr  - Pointer to object.
  51.  
  52.     RESULT
  53.  
  54.     NOTES
  55.  
  56.     EXAMPLE
  57.  
  58.     BUGS
  59.  
  60.     SEE ALSO
  61.  
  62.     INTERNALS
  63.  
  64.     HISTORY
  65.     29-10-95    digulla automatically created from
  66.                 dos_lib.fd and clib/dos_protos.h
  67.  
  68. *****************************************************************************/
  69. {
  70.     AROS_LIBFUNC_INIT
  71.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  72.  
  73.     switch(type)
  74.     {
  75.     case DOS_FILEHANDLE:
  76.     {
  77.         struct FileHandle *fh=(struct FileHandle *)ptr;
  78.         if(fh->fh_Flags&FHF_BUF)
  79.         FreeMem(fh->fh_Buf,fh->fh_Size);
  80.         FreeMem(fh,sizeof(struct FileHandle));
  81.         break;
  82.     }
  83.     case DOS_FIB:
  84.         FreeMem(ptr,sizeof(struct FileInfoBlock));
  85.         break;
  86.     case DOS_EXALLCONTROL:
  87.         FreeMem(ptr,sizeof(struct ExAllControl));
  88.         break;
  89.     case DOS_CLI:
  90.     {
  91.         struct CommandLineInterface *cli=(struct CommandLineInterface *)ptr;
  92.         BPTR *cur, *next;
  93.         cur=(BPTR *)BADDR(cli->cli_CommandDir);
  94.         FreeMem(ptr,sizeof(struct CommandLineInterface));
  95.         while(cur!=NULL)
  96.         {
  97.         next=(BPTR *)BADDR(cur[0]);
  98.         UnLock(cur[1]);
  99.         FreeVec(cur);
  100.         cur=next;
  101.         }
  102.         break;
  103.     }
  104.     }
  105.     AROS_LIBFUNC_EXIT
  106. } /* FreeDosObject */
  107.