Fix for the (stupid) case of app (always) passing
[tangerine.git] / rom / dos / freedosobject.c
blobd79ef5ae7a113bad3f10856ba4f7ee35b13623fa
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <exec/memory.h>
9 #include <proto/exec.h>
10 #include <dos/exall.h>
11 #include <dos/rdargs.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/dos.h>
19 AROS_LH2(void, FreeDosObject,
21 /* SYNOPSIS */
22 AROS_LHA(ULONG, type, D1),
23 AROS_LHA(APTR, ptr, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 39, Dos)
28 /* FUNCTION
29 Frees an object allocated with AllocDosObject.
31 INPUTS
32 type - object type. The same parameter as given to AllocDosObject().
33 ptr - Pointer to object.
35 RESULT
37 NOTES
39 EXAMPLE
41 BUGS
43 SEE ALSO
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
50 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
52 switch(type)
54 case DOS_FILEHANDLE:
56 struct FileHandle *fh=(struct FileHandle *)ptr;
57 if(fh->fh_Flags&FHF_BUF)
58 FreeMem(fh->fh_Buf,fh->fh_Size);
59 FreeMem(fh,sizeof(struct FileHandle));
60 break;
62 case DOS_FIB:
63 FreeMem(ptr,sizeof(struct FileInfoBlock));
64 break;
66 case DOS_STDPKT:
67 FreeMem((APTR)(ptr-(APTR)(&((struct StandardPacket *)0)->sp_Pkt)),sizeof(struct StandardPacket));
68 break;
70 case DOS_EXALLCONTROL:
71 if (((struct InternalExAllControl *)ptr)->fib)
72 FreeDosObject(DOS_FIB, ((struct InternalExAllControl *)ptr)->fib);
74 FreeMem(ptr, sizeof(struct InternalExAllControl));
75 break;
77 case DOS_CLI:
79 struct CommandLineInterface *cli=(struct CommandLineInterface *)ptr;
80 BPTR *cur, *next;
81 cur=(BPTR *)BADDR(cli->cli_CommandDir);
82 FreeVec(BADDR(cli->cli_SetName));
83 FreeVec(BADDR(cli->cli_CommandName));
84 FreeVec(BADDR(cli->cli_CommandFile));
85 FreeVec(BADDR(cli->cli_Prompt));
86 FreeMem(ptr,sizeof(struct CommandLineInterface));
87 while(cur!=NULL)
89 next=(BPTR *)BADDR(cur[0]);
90 UnLock(cur[1]);
91 FreeVec(cur);
92 cur=next;
94 break;
97 FreeArgs() will not free a RDArgs without a RDA_DAList,
98 see that function for more information as to why...
100 case DOS_RDARGS:
101 if(((struct RDArgs *)ptr)->RDA_DAList != NULL)
102 FreeArgs(ptr);
103 else
104 FreeVec(ptr);
106 break;
109 AROS_LIBFUNC_EXIT
110 } /* FreeDosObject */