aros/m68k/fpucontext.h: Remove dependence on _fpmath.h
[AROS.git] / rom / exec / deallocate.c
blob06b638b27e4252683329bddb6a5425b02353156f
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Free memory allocated by Allocate().
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/execbase.h>
11 #include <exec/alerts.h>
12 #include <aros/libcall.h>
13 #include <exec/memory.h>
14 #include <proto/exec.h>
16 #include "exec_util.h"
17 #include "memory.h"
19 /*****************************************************************************
21 NAME */
23 AROS_LH3(void, Deallocate,
25 /* SYNOPSIS */
26 AROS_LHA(struct MemHeader *, freeList, A0),
27 AROS_LHA(APTR, memoryBlock, A1),
28 AROS_LHA(ULONG, byteSize, D0),
30 /* LOCATION */
31 struct ExecBase *, SysBase, 32, Exec)
33 /* FUNCTION
34 Free block of memory associated with a given MemHandler structure.
36 INPUTS
37 freeList - Pointer to the MemHeader structure
38 memoryBlock - Pointer to the memory to be freed
39 byteSize - Size of the block
41 RESULT
43 NOTES
44 The start and end borders of the block are aligned to
45 a multiple of sizeof(struct MemChunk) and to include the block.
47 EXAMPLE
49 BUGS
51 SEE ALSO
52 Allocate()
54 INTERNALS
56 ******************************************************************************/
58 AROS_LIBFUNC_INIT
60 struct TraceLocation tp = CURRENT_LOCATION("Deallocate");
62 /* If there is no memory free nothing */
63 if(!byteSize || !memoryBlock)
64 return;
66 #if !defined(NO_CONSISTENCY_CHECKS)
67 /* Test if our block really fits into this MemHeader. */
68 if ((memoryBlock < freeList->mh_Lower) || (memoryBlock + byteSize > freeList->mh_Upper + 1))
70 /* Something is completely wrong. */
71 bug("[MM] Memory allocator error\n");
72 bug("[MM] Attempt to free %u bytes at 0x%p from MemHeader 0x%p\n", byteSize, memoryBlock, freeList);
73 bug("[MM] Block does not fit into MemHeader (0x%p - 0x%p)\n", freeList->mh_Lower, freeList->mh_Upper);
75 Alert(AN_BadFreeAddr);
76 return;
78 #endif
80 stdDealloc(freeList, memoryBlock, byteSize, &tp, SysBase);
82 AROS_LIBFUNC_EXIT
83 } /* Deallocate */