@@ -33,7 +33,7 @@ struct MemHeader *FindMem(APTR address, struct ExecBase *SysBase)
3333
3434 while (mh -> mh_Node .ln_Succ != NULL )
3535 {
36- #ifdef HANDLE_MANAGED_MEM
36+ #if HANDLE_MANAGED_MEM
3737 if (IsManagedMem (mh ))
3838 {
3939 struct MemHeaderExt * mhe = (struct MemHeaderExt * )mh ;
@@ -376,7 +376,8 @@ void mhac_PoolMemHeaderSetup(struct MemHeader * mh, struct ProtectedPool * pool)
376376#define mhac_PoolMemHeaderGetCtx (a ) ((struct MemHeaderAllocatorCtx *)(a->mh_Node.ln_Name))
377377#define mhac_PoolMemHeaderGetPool (a ) (mhac_PoolMemHeaderGetCtx(a)->mhac_Data1)
378378
379- #endif
379+ #endif // defined(NO_ALLOCATOR_CONTEXT)
380+
380381
381382
382383#ifdef NO_CONSISTENCY_CHECKS
@@ -540,12 +541,8 @@ APTR stdAllocReverse(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, I
540541 struct MemChunk * pp = p1 ;
541542
542543 /* Return the last bytes. */
543- p1 -> mc_Next = p2 ;
544544 mc = (struct MemChunk * )(MK_UBYTEPTR (p2 )+ p2 -> mc_Bytes - byteSize );
545-
546- p1 = p1 -> mc_Next ;
547- p1 -> mc_Next = p2 -> mc_Next ;
548- p1 -> mc_Bytes = p2 -> mc_Bytes - byteSize ;
545+ p2 -> mc_Bytes -= byteSize ;
549546
550547 mhac_MemChunkCreated (p1 , pp , mhac );
551548 }
@@ -556,7 +553,7 @@ APTR stdAllocReverse(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, I
556553 if (requirements & MEMF_CLEAR )
557554 memset (mc , 0 , byteSize );
558555 }
559-
556+ #if !defined( NO_ALLOCATOR_CONTEXT )
560557 else
561558 {
562559 if (!mhac_IsIndexEmpty (mhac ))
@@ -569,6 +566,7 @@ APTR stdAllocReverse(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, I
569566 mc = stdAlloc (mh , mhac , size , requirements , tp , SysBase );
570567 }
571568 }
569+ #endif
572570 return mc ;
573571}
574572
@@ -588,7 +586,7 @@ APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR siz
588586 * The check has to be done for the second time. Exec uses stdAlloc on memheader
589587 * passed upon startup. This is bad, very bad. So here a temporary hack :)
590588 */
591- #ifdef HANDLE_MANAGED_MEM
589+ #if HANDLE_MANAGED_MEM
592590 if ((mh -> mh_Node .ln_Type == NT_MEMORY ) && IsManagedMem (mh ))
593591 {
594592 struct MemHeaderExt * mhe = (struct MemHeaderExt * )mh ;
@@ -654,7 +652,6 @@ APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR siz
654652 /* Something found? */
655653 if (mc != NULL )
656654 {
657- /* Remember: if MEMF_REVERSE is set p1 and p2 are now invalid. */
658655 p1 = mc ;
659656 p2 = p1 -> mc_Next ;
660657
@@ -688,6 +685,7 @@ APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR siz
688685 if (requirements & MEMF_CLEAR )
689686 memset (mc , 0 , byteSize );
690687 }
688+ #if !defined(NO_ALLOCATOR_CONTEXT )
691689 else
692690 {
693691 if (!mhac_IsIndexEmpty (mhac ))
@@ -700,7 +698,8 @@ APTR stdAlloc(struct MemHeader *mh, struct MemHeaderAllocatorCtx *mhac, IPTR siz
700698 mc = stdAlloc (mh , mhac , size , requirements , tp , SysBase );
701699 }
702700 }
703- return mc ;
701+ #endif
702+ return mc ;
704703 }
705704}
706705
@@ -716,7 +715,7 @@ void stdDealloc(struct MemHeader *freeList, struct MemHeaderAllocatorCtx *mhac,
716715 struct MemChunk * p1 , * p2 , * p3 ;
717716 UBYTE * p4 ;
718717
719- #ifdef HANDLE_MANAGED_MEM
718+ #if HANDLE_MANAGED_MEM
720719 if ((freeList -> mh_Node .ln_Type == NT_MEMORY ) && IsManagedMem (freeList ))
721720 {
722721 struct MemHeaderExt * mhe = (struct MemHeaderExt * )freeList ;
@@ -774,7 +773,7 @@ void stdDealloc(struct MemHeader *freeList, struct MemHeaderAllocatorCtx *mhac,
774773 /* Found a block with a higher address? */
775774 if (p2 >= p3 )
776775 {
777- #if !defined(NO_CONSISTENCY_CHECKS )
776+ // #if !defined(NO_CONSISTENCY_CHECKS)
778777 /*
779778 If the memory to be freed overlaps with the current
780779 block something must be wrong.
@@ -788,7 +787,7 @@ void stdDealloc(struct MemHeader *freeList, struct MemHeaderAllocatorCtx *mhac,
788787 Alert (AN_FreeTwice );
789788 return ;
790789 }
791- #endif
790+ // #endif
792791 /* End the loop with p2 non-zero */
793792 break ;
794793 }
@@ -889,7 +888,7 @@ APTR AllocMemHeader(IPTR size, ULONG flags, struct TraceLocation *loc, struct Ex
889888 {
890889 struct MemHeader * orig = FindMem (mh , SysBase );
891890
892- #ifdef HANDLE_MANAGED_MEM
891+ #if HANDLE_MANAGED_MEM
893892 if (IsManagedMem (orig ))
894893 {
895894 struct MemHeaderExt * mhe_orig = (struct MemHeaderExt * )orig ;
@@ -964,7 +963,7 @@ void FreeMemHeader(APTR addr, struct TraceLocation *loc, struct ExecBase *SysBas
964963
965964 IPTR size = (IPTR )mhe -> mhe_MemHeader .mh_Upper - (IPTR )addr ;
966965
967- #ifdef HANDLE_MANAGED_MEM
966+ #if HANDLE_MANAGED_MEM
968967 if (IsManagedMem (mhe ))
969968 {
970969 if (mhe -> mhe_DestroyPool )
@@ -1038,6 +1037,7 @@ APTR InternalAllocPooled(APTR poolHeader, IPTR memSize, ULONG flags, struct Trac
10381037 if (pool -> pool .PoolMagic != POOL_MAGIC )
10391038 {
10401039 PoolManagerAlert (PME_ALLOC_INV_POOL , AT_DeadEnd , memSize , NULL , NULL , poolHeader );
1040+ return NULL ;
10411041 }
10421042
10431043 if (pool -> pool .Requirements & MEMF_SEM_PROTECTED )
@@ -1207,11 +1207,13 @@ void InternalFreePooled(APTR poolHeader, APTR memory, IPTR memSize, struct Trace
12071207 if (pool -> pool .PoolMagic != POOL_MAGIC )
12081208 {
12091209 PoolManagerAlert (PME_FREE_INV_POOL , AT_DeadEnd , memSize , memory , poolHeaderMH , NULL );
1210+ return ;
12101211 }
12111212
12121213 if (poolHeaderMH != poolHeader )
12131214 {
12141215 PoolManagerAlert (PME_FREE_MXD_POOL , 0 , memSize , memory , poolHeaderMH , poolHeader );
1216+ return ;
12151217 }
12161218
12171219 if (pool -> pool .Requirements & MEMF_SEM_PROTECTED )
0 commit comments