some fixes to accented characters
[tangerine.git] / rom / dos / freedosobject.c
blob1759ed33dd6263ca5a87fe06b5f959e20151ac49
1 /*
2 Copyright © 1995-2007, 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
51 switch(type)
53 case DOS_FILEHANDLE:
55 struct FileHandle *fh=(struct FileHandle *)ptr;
56 if(fh->fh_Flags&FHF_BUF)
57 FreeMem(fh->fh_Buf,fh->fh_Size);
58 FreeMem(fh,sizeof(struct FileHandle));
59 break;
61 case DOS_FIB:
62 FreeMem(ptr,sizeof(struct FileInfoBlock));
63 break;
65 case DOS_STDPKT:
66 FreeMem((APTR)(ptr-(APTR)(&((struct StandardPacket *)0)->sp_Pkt)),sizeof(struct StandardPacket));
67 break;
69 case DOS_EXALLCONTROL:
70 if (((struct InternalExAllControl *)ptr)->fib)
71 FreeDosObject(DOS_FIB, ((struct InternalExAllControl *)ptr)->fib);
73 FreeMem(ptr, sizeof(struct InternalExAllControl));
74 break;
76 case DOS_CLI:
78 struct CommandLineInterface *cli=(struct CommandLineInterface *)ptr;
79 BPTR *cur, *next;
80 cur=(BPTR *)BADDR(cli->cli_CommandDir);
81 FreeVec(BADDR(cli->cli_SetName));
82 FreeVec(BADDR(cli->cli_CommandName));
83 FreeVec(BADDR(cli->cli_CommandFile));
84 FreeVec(BADDR(cli->cli_Prompt));
85 FreeMem(ptr,sizeof(struct CommandLineInterface));
86 while(cur!=NULL)
88 next=(BPTR *)BADDR(cur[0]);
89 UnLock(cur[1]);
90 FreeVec(cur);
91 cur=next;
93 break;
96 FreeArgs() will not free a RDArgs without a RDA_DAList,
97 see that function for more information as to why...
99 case DOS_RDARGS:
100 if(((struct RDArgs *)ptr)->RDA_DAList != NULL)
101 FreeArgs(ptr);
102 else
103 FreeVec(ptr);
105 break;
108 AROS_LIBFUNC_EXIT
109 } /* FreeDosObject */