2 Copyright © 1995-2010, 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 /*****************************************************************************
42 AROS_LH2(void, FreeMem
,
45 AROS_LHA(APTR
, memoryBlock
, A1
),
46 AROS_LHA(ULONG
, byteSize
, D0
),
49 struct ExecBase
*, SysBase
, 35, Exec
)
52 Give a block of memory back to the system pool.
55 memoryBlock - Pointer to the memory to be freed
56 byteSize - Size of the block
71 ******************************************************************************/
75 ULONG origsize
= byteSize
;
77 D(bug("Call FreeMem (%08lx, %ld)\n", memoryBlock
, byteSize
));
79 /* If there is no memory free nothing */
80 if(!byteSize
|| !memoryBlock
)
81 ReturnVoid ("FreeMem");
84 RT_Free(RTT_MEMORY
, memoryBlock
, byteSize
);
87 /* In early boot mode we can't free any memory */
88 if (!PrivExecBase(SysBase
)->defaultPool
)
91 FreePooled(PrivExecBase(SysBase
)->defaultPool
, memoryBlock
, byteSize
);
93 ReturnVoid ("FreeMem");