From c0f65518a5dab885e972996b7eae6706780578a1 Mon Sep 17 00:00:00 2001 From: schulz Date: Sun, 12 May 2013 19:55:43 +0000 Subject: [PATCH] Allocate supports MEMF_MANAGED too git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47404 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/exec/allocate.c | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/rom/exec/allocate.c b/rom/exec/allocate.c index a8a9023069..ba1766b2e8 100644 --- a/rom/exec/allocate.c +++ b/rom/exec/allocate.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "exec_intern.h" @@ -83,27 +84,39 @@ AROS_LH2(APTR, Allocate, { AROS_LIBFUNC_INIT - struct TraceLocation tp = CURRENT_LOCATION("Allocate"); - APTR res; + if (freeList->mh_Attributes & MEMF_MANAGED) + { + struct MemHeaderExt *mhe = (struct MemHeaderExt *)freeList; - D(bug("[exec] Allocate(0x%p, %u)\n", freeList, byteSize)); - ASSERT_VALID_PTR(freeList); + if (mhe->mhe_Alloc) + return mhe->mhe_Alloc(mhe, byteSize, NULL); + else + return NULL; + } + else + { + struct TraceLocation tp = CURRENT_LOCATION("Allocate"); + APTR res; - /* Zero bytes requested? May return everything ;-). */ - if(!byteSize) - return NULL; + D(bug("[exec] Allocate(0x%p, %u)\n", freeList, byteSize)); + ASSERT_VALID_PTR(freeList); - /* Is there enough free memory in the list? */ - if(freeList->mh_Freemh_FreeIntFlags & EXECF_MungWall) && res) { - MUNGE_BLOCK(res, MEMFILL_ALLOC, byteSize); - } + res = stdAlloc(freeList, NULL /* by design */, byteSize, 0, &tp, SysBase); - return res; + if ((PrivExecBase(SysBase)->IntFlags & EXECF_MungWall) && res) { + MUNGE_BLOCK(res, MEMFILL_ALLOC, byteSize); + } + + return res; + } AROS_LIBFUNC_EXIT } /* Allocate() */ -- 2.11.4.GIT