2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 Desc: Free memory allocated by AllocMem()
8 #include <exec/alerts.h>
9 #include <exec/execbase.h>
10 #include <aros/libcall.h>
11 #include <aros/config.h>
12 #include <aros/macros.h>
14 #include <exec/memory.h>
15 #include <exec/memheaderext.h>
16 #include <proto/exec.h>
18 #include "exec_debug.h"
21 # define DEBUG_FreeMem 0
29 #include <aros/debug.h>
33 #include "exec_intern.h"
36 #undef FreeMem /* If we're debugging, AROS Clib will try to remap this */
38 /* See rom/exec/freemem.c for documentation */
40 AROS_LH2(void, FreeMem
,
41 AROS_LHA(APTR
, memoryBlock
, A1
),
42 AROS_LHA(IPTR
, byteSize
, D0
),
43 struct ExecBase
*, SysBase
, 35, Exec
)
47 ULONG origsize
= byteSize
;
49 D(bug("Call FreeMem (%08lx, %ld)\n", memoryBlock
, byteSize
));
51 /* If there is no memory free nothing */
52 if(!byteSize
|| !memoryBlock
)
53 ReturnVoid ("FreeMem");
56 RT_Free(RTT_MEMORY
, memoryBlock
, byteSize
);
59 /* In early boot mode we can't free any memory */
60 if (!PrivExecBase(SysBase
)->defaultPool
)
63 FreePooled(PrivExecBase(SysBase
)->defaultPool
, memoryBlock
, byteSize
);
65 ReturnVoid ("FreeMem");