Detabbed
[AROS.git] / rom / dos / freeargs.c
blobb4e85b499a5e4c197ca6755e0c875e867e0c6984
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Free arguments structure from ReadArgs()
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include <dos/rdargs.h>
10 #include "dos_intern.h"
12 /*****************************************************************************
14 NAME */
15 #include <proto/dos.h>
17 AROS_NTLH1(void, FreeArgs,
19 /* SYNOPSIS */
20 AROS_LHA(struct RDArgs *, args, D1),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 143, Dos)
25 /* FUNCTION
26 FreeArgs() will clean up after a call to ReadArgs(). If the
27 RDArgs structure was allocated by the system in a call to
28 ReadArgs(), then it will be freed. If however, you allocated
29 the RDArgs structure with AllocDosObject(), then you will
30 have to free it yourself with FreeDosObject().
32 INPUTS
33 args - The data used by ReadArgs(). May be NULL,
34 in which case, FreeArgs() does nothing.
36 RESULT
37 Some memory will have been returned to the system.
39 NOTES
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 ReadArgs()
48 INTERNALS
50 *****************************************************************************/
52 AROS_LIBFUNC_INIT
54 if(!args)
55 return;
57 /* ReadArgs() failed. Clean everything up. */
58 if (args->RDA_DAList)
60 FreeVec(((struct DAList *)args->RDA_DAList)->ArgBuf);
61 FreeVec(((struct DAList *)args->RDA_DAList)->StrBuf);
62 FreeVec(((struct DAList *)args->RDA_DAList)->MultVec);
63 FreeVec((struct DAList *)args->RDA_DAList);
65 args->RDA_DAList = 0;
67 #if 0
69 Why do I put this here. Unless the user has been bad and
70 set RDA_DAList to something other than NULL, then this
71 RDArgs structure was allocated by ReadArgs(), so we can
72 free it. Otherwise the RDArgs was allocated by
73 AllocDosObject(), so we are not allowed to free it.
75 See the original AmigaOS autodoc if you don't believe me
78 FreeVec(args);
79 #endif
82 if (args->RDA_Flags & RDAF_ALLOCATED_BY_READARGS)
83 FreeVec(args);
85 AROS_LIBFUNC_EXIT
87 } /* FreeArgs */