1
0
mirror of https://github.com/adtools/clib2.git synced 2025-12-08 14:59:05 +00:00

Small changes to the code documentation

The memory pools store puddles near head of the allocation list and the large allocations near the tail of the list.

Some hints added to point to side-effects which might apply to memory allocation operations.
This commit is contained in:
obarthel
2021-12-23 13:08:08 +01:00
parent b7ce13cbf8
commit ff5826c54e

View File

@@ -63,8 +63,8 @@ struct MemoryPool
struct MinList mp_PuddleMinList; /* Both puddles and large allocations struct MinList mp_PuddleMinList; /* Both puddles and large allocations
* are stored in this list. The puddles * are stored in this list. The puddles
* are stored near the head of the list * are stored near the head of the list
* and the puddles are stored near the * and the large allocations are stored
* tail of the list. * near the tail of the list.
*/ */
ULONG mp_MemoryFlags; /* Memory attributes for allocation */ ULONG mp_MemoryFlags; /* Memory attributes for allocation */
@@ -160,6 +160,7 @@ static APTR alloc_vec(ULONG size, ULONG flags)
if (size > 0) if (size > 0)
{ {
/* Note: no overflow testing is being performed! */
size += sizeof(*mem); size += sizeof(*mem);
mem = AllocMem(size, flags); mem = AllocMem(size, flags);
@@ -235,6 +236,8 @@ APTR LibCreatePool(
/* Round up the puddle size to the size of a /* Round up the puddle size to the size of a
* memory block, as managed by Allocate(). * memory block, as managed by Allocate().
*
* Note: no overflow checking is performed!
*/ */
puddle_size = (puddle_size + MEM_BLOCKMASK) & ~MEM_BLOCKMASK; puddle_size = (puddle_size + MEM_BLOCKMASK) & ~MEM_BLOCKMASK;
@@ -277,6 +280,8 @@ static union PuddleUnion * create_new_puddle(struct MemoryPool * mp)
/* The extra sizeof(APTR) is needed for aligning the /* The extra sizeof(APTR) is needed for aligning the
* allocatable memory chunks within the memory header. * allocatable memory chunks within the memory header.
*
* Note: no overflow checking is performed!
*/ */
pu = alloc_vec(sizeof(pu->pu_MemHeader) + puddle_size + sizeof(APTR), memory_flags); pu = alloc_vec(sizeof(pu->pu_MemHeader) + puddle_size + sizeof(APTR), memory_flags);
if (pu == NULL) if (pu == NULL)
@@ -400,6 +405,7 @@ APTR LibAllocPooled(APTR pool, ULONG mem_size)
{ {
struct LargeAllocation * la; struct LargeAllocation * la;
/* Note: no overflow checking is performed! */
pu = alloc_vec(sizeof(pu->pu_LargeAllocation) + mem_size, mp->mp_MemoryFlags); pu = alloc_vec(sizeof(pu->pu_LargeAllocation) + mem_size, mp->mp_MemoryFlags);
if (pu == NULL) if (pu == NULL)
goto out; goto out;