2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
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 /*****************************************************************************
17 #include <proto/dos.h>
19 AROS_LH2(void, FreeDosObject
,
22 AROS_LHA(ULONG
, type
, D1
),
23 AROS_LHA(APTR
, ptr
, D2
),
26 struct DosLibrary
*, DOSBase
, 39, Dos
)
29 Frees an object allocated with AllocDosObject.
32 type - object type. The same parameter as given to AllocDosObject().
33 ptr - Pointer to object.
47 *****************************************************************************/
58 struct FileHandle
*fh
=(struct FileHandle
*)ptr
;
59 if (fh
->fh_Flags
& FHF_OWNBUF
)
60 FreeMem(BADDR(fh
->fh_Buf
),fh
->fh_BufSize
);
61 FreeMem(fh
,sizeof(struct FileHandle
));
65 FreeMem(ptr
,sizeof(struct FileInfoBlock
));
72 case DOS_EXALLCONTROL
:
73 if (((struct InternalExAllControl
*)ptr
)->fib
)
74 FreeDosObject(DOS_FIB
, ((struct InternalExAllControl
*)ptr
)->fib
);
76 FreeMem(ptr
, sizeof(struct InternalExAllControl
));
81 struct CommandLineInterface
*cli
=(struct CommandLineInterface
*)ptr
;
83 cur
=(BPTR
*)BADDR(cli
->cli_CommandDir
);
84 FreeVec(BADDR(cli
->cli_SetName
));
85 FreeVec(BADDR(cli
->cli_CommandName
));
86 FreeVec(BADDR(cli
->cli_CommandFile
));
87 FreeVec(BADDR(cli
->cli_Prompt
));
88 FreeMem(ptr
,sizeof(struct CommandLineInterface
));
91 next
=(BPTR
*)BADDR(cur
[0]);
99 FreeArgs() will not free a RDArgs without a RDA_DAList,
100 see that function for more information as to why...
103 if(((struct RDArgs
*)ptr
)->RDA_DAList
!= NULL
)
112 } /* FreeDosObject */
114 #define offsetof(TYPE, MEMBER) ((IPTR) &((TYPE *)0)->MEMBER)
115 #define container_of(ptr, type, member) ({ \
116 const typeof(((type *)0)->member) *__mptr = (ptr); \
117 (type *)((char *)__mptr - offsetof(type, member)); })
119 void freedospacket(struct DosPacket
*dp
)
121 FreeMem(container_of(dp
, struct StandardPacket
, sp_Pkt
), sizeof(struct StandardPacket
));