From 647bafe47bf5157db586bfa958401da60a63f223 Mon Sep 17 00:00:00 2001 From: deadwood Date: Sat, 1 Jun 2013 06:22:37 +0000 Subject: [PATCH] exec.library: AllocAbs will no longer allocate MemHeaderAllocatorCtx git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@47490 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/exec/memory.c | 23 +++++++++++++++++++---- rom/exec/memory.h | 4 +++- rom/exec/memory_nommu.c | 3 ++- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/rom/exec/memory.c b/rom/exec/memory.c index fef4782e38..3856384102 100644 --- a/rom/exec/memory.c +++ b/rom/exec/memory.c @@ -114,15 +114,16 @@ void mhac_PoolMemHeaderSetup(struct MemHeader * mh, struct ProtectedPool * pool) mh->mh_Node.ln_Name = (STRPTR)pool; } -void mhac_MemChunkClaimed(struct MemChunk * mc, struct MemHeaderAllocatorCtx * mhac) +ULONG mhac_GetCtxSize() { + return 0; } -ULONG mhac_GetCtxSize() +void mhac_ClearSysCtx(struct MemHeader * mh, struct ExecBase * SysBase) { - return 0; } +#define mhac_MemChunkClaimed(a, b) #define mhac_IsIndexEmpty(a) (TRUE) #define mhac_ClearIndex(a) #define mhac_MemChunkCreated(a, b, c) { (void)b; } @@ -214,6 +215,20 @@ static void mhac_SetupMemHeaderAllocatorCtx(struct MemHeader * mh, ULONG maxinde mhac_ClearIndex(mhac); } +void mhac_ClearSysCtx(struct MemHeader * mh, struct ExecBase * SysBase) +{ + struct MemHeaderAllocatorCtx * mhac = NULL; + + ForeachNode(&PrivExecBase(SysBase)->AllocatorCtxList, mhac) + { + if (mhac->mhac_MemHeader == mh) + { + mhac_ClearIndex(mhac); + break; + } + } +} + struct MemHeaderAllocatorCtx * mhac_GetSysCtx(struct MemHeader * mh, struct ExecBase * SysBase) { struct MemHeaderAllocatorCtx * mhac = NULL; @@ -232,7 +247,7 @@ struct MemHeaderAllocatorCtx * mhac_GetSysCtx(struct MemHeader * mh, struct Exec return mhac; } -void mhac_MemChunkClaimed(struct MemChunk * mc, struct MemHeaderAllocatorCtx * mhac) +static void mhac_MemChunkClaimed(struct MemChunk * mc, struct MemHeaderAllocatorCtx * mhac) { LONG i; diff --git a/rom/exec/memory.h b/rom/exec/memory.h index 28ed848b03..36a9d15c50 100644 --- a/rom/exec/memory.h +++ b/rom/exec/memory.h @@ -60,10 +60,12 @@ struct TraceLocation; struct MemHeaderAllocatorCtx; +/* Returns existing or allocates new ctx */ struct MemHeaderAllocatorCtx * mhac_GetSysCtx(struct MemHeader * mh, struct ExecBase * SysBase); void mhac_PoolMemHeaderSetup(struct MemHeader * mh, struct ProtectedPool * pool); -void mhac_MemChunkClaimed(struct MemChunk * mc, struct MemHeaderAllocatorCtx * mhac); ULONG mhac_GetCtxSize(); +/* Clears ctx if it already exists for a given MemHeader */ +void mhac_ClearSysCtx(struct MemHeader * mh, struct ExecBase * SysBase); struct MemHeader *FindMem(APTR address, struct ExecBase *SysBase); APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR byteSize, ULONG requirements, struct TraceLocation *loc, struct ExecBase *SysBase); diff --git a/rom/exec/memory_nommu.c b/rom/exec/memory_nommu.c index 9d5443abb7..7d409be9ba 100644 --- a/rom/exec/memory_nommu.c +++ b/rom/exec/memory_nommu.c @@ -156,7 +156,8 @@ APTR nommu_AllocAbs(APTR location, IPTR byteSize, struct ExecBase *SysBase) /* Found a chunk that fits? */ if((UBYTE *)p2+p2->mc_Bytes>=(UBYTE *)p4&&p2<=p3) { - mhac_MemChunkClaimed(p2, mhac_GetSysCtx(mh, SysBase)); + /* Since AllocAbs allocations never allocate/update a ctx, they need to clear it if it exists */ + mhac_ClearSysCtx(mh, SysBase); /* Check if there's memory left at the end. */ if((UBYTE *)p2+p2->mc_Bytes!=(UBYTE *)p4) -- 2.11.4.GIT