revert between 56095 -> 55830 in arch
[AROS.git] / rom / exec / freevecpooled.c
blob845692fa857231809dae43e9d2a1a4d91fd87e24
1 /*
2 Copyright � 2003-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/libcall.h>
7 #include <proto/exec.h>
8 #include <exec/memheaderext.h>
10 #include "exec_intern.h"
12 /*****************************************************************************
14 NAME */
16 AROS_LH2(void, FreeVecPooled,
18 /* SYNOPSIS */
19 AROS_LHA(APTR, poolHeader, A0),
20 AROS_LHA(APTR, memory, A1),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 170, Exec)
25 /* FUNCTION
26 Free memory that was allocated out of a private memory pool by
27 AllocVecPooled().
29 INPUTS
30 poolHeader - Handle of the memory pool
31 memory - Pointer to the memory
33 RESULT
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 CreatePool(), DeletePool(), AllocVecPooled()
44 INTERNALS
45 In AROS memory allocated from pool remembers where it came from.
46 Because of this poolHeader is effectively ignored and is present
47 only for compatibility reasons. However, do not rely on this! For
48 other operating systems of Amiga(tm) family this is not true!
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 struct MemHeaderExt *mhe = (struct MemHeaderExt *)poolHeader;
56 /* If there is nothing to free do nothing. */
57 if(!memory)
58 return;
60 if (IsManagedMem(mhe))
62 if (mhe->mhe_FreeVec)
63 mhe->mhe_FreeVec(mhe, memory);
65 else
67 if (memory != NULL)
69 IPTR *real = (IPTR *) memory;
70 IPTR size = *--real;
72 FreePooled(poolHeader, real, size);
75 AROS_LIBFUNC_EXIT
76 } /* FreeVecPooled() */