exec.library: Use the new AROS_UFIx() macros
[AROS.git] / rom / exec / freemem.c
blob5d91c29447e069c15f0a79f0e90e9db5a41f9ee6
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Free memory allocated by AllocMem()
6 Lang: english
7 */
9 #include <exec/alerts.h>
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
12 #include <aros/config.h>
13 #include <aros/macros.h>
14 #include <aros/rt.h>
15 #include <exec/memory.h>
16 #include <exec/memheaderext.h>
17 #include <proto/exec.h>
19 #include "exec_intern.h"
20 #include "exec_util.h"
21 #include "memory.h"
22 #include "mungwall.h"
24 #undef FreeMem /* If we're debugging, AROS Clib will try to remap this */
26 /*****************************************************************************
28 NAME */
30 AROS_LH2(void, FreeMem,
32 /* SYNOPSIS */
33 AROS_LHA(APTR, memoryBlock, A1),
34 AROS_LHA(ULONG, byteSize, D0),
36 /* LOCATION */
37 struct ExecBase *, SysBase, 35, Exec)
39 /* FUNCTION
40 Give a block of memory back to the system pool.
42 INPUTS
43 memoryBlock - Pointer to the memory to be freed
44 byteSize - Size of the block
46 RESULT
48 NOTES
50 EXAMPLE
52 BUGS
54 SEE ALSO
55 AllocMem()
57 INTERNALS
59 ******************************************************************************/
61 AROS_LIBFUNC_INIT
63 struct TraceLocation tp = CURRENT_LOCATION("FreeMem");
65 D(bug("Call FreeMem (%08lx, %ld)\n", memoryBlock, byteSize));
67 /* If there is no memory free nothing */
68 if(!byteSize || !memoryBlock)
69 ReturnVoid ("FreeMem");
71 RT_Free (RTT_MEMORY, memoryBlock, byteSize);
73 memoryBlock = MungWall_Check(memoryBlock, byteSize, &tp, SysBase);
75 if (PrivExecBase(SysBase)->IntFlags & EXECF_MungWall)
76 byteSize += MUNGWALL_TOTAL_SIZE;
78 InternalFreeMem(memoryBlock, byteSize, &tp, SysBase);
80 ReturnVoid ("FreeMem");
82 AROS_LIBFUNC_EXIT
83 } /* FreeMem */