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

Added an assertion to verify that the first free chunk on the slab's list is really always available.

This commit is contained in:
obarthel
2023-09-09 12:55:01 +02:00
parent 4f3d0c981c
commit 115099698a

6
library/stdlib_slab.c Executable file → Normal file
View File

@ -417,8 +417,8 @@ __slab_allocate(size_t allocation_size)
* padding added to make the first allocatable slab start on
* a 64 bit boundary.
*/
aligned_first_byte = ((ULONG)&new_sn[1] + MEM_BLOCKMASK) & ~MEM_BLOCKMASK;
aligned_first_byte = (((ULONG)&new_sn[1]) + MEM_BLOCKMASK) & ~MEM_BLOCKMASK;
first_byte = (BYTE *)aligned_first_byte;
last_byte = &first_byte[__slab_data.sd_StandardSlabSize - chunk_size];
@ -446,6 +446,8 @@ __slab_allocate(size_t allocation_size)
/* Grab the first free chunk (there has to be one). */
chunk = (struct SlabChunk *)RemHead((struct List *)&new_sn->sn_FreeList);
assert( chunk != NULL );
/* Keep track of this chunk's parent slab. */
chunk->sc_ParentSlab = new_sn;