2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: Free memory allocated by AllocMem()
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>
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"
24 #undef FreeMem /* If we're debugging, AROS Clib will try to remap this */
26 /*****************************************************************************
30 AROS_LH2(void, FreeMem
,
33 AROS_LHA(APTR
, memoryBlock
, A1
),
34 AROS_LHA(IPTR
, byteSize
, D0
),
37 struct ExecBase
*, SysBase
, 35, Exec
)
40 Give a block of memory back to the system pool.
43 memoryBlock - Pointer to the memory to be freed
44 byteSize - Size of the block
59 ******************************************************************************/
63 struct TraceLocation tp
= CURRENT_LOCATION("FreeMem");
65 D(bug("Call FreeMem (%08lx, %ld)\n", memoryBlock
, byteSize
));
67 /* If there is nothing to free do 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");