Fix iterations through arenas

This commit is contained in:
Lysandros Nikolaou 2025-02-14 19:05:39 +01:00
parent 19154a5478
commit 7d2ea7665f
No known key found for this signature in database
GPG Key ID: 43E92D11D08F5F29
2 changed files with 4 additions and 4 deletions

View File

@ -195,13 +195,13 @@ typedef struct ImagingMemoryArena {
* will allocate a set of arenas and associated them with threads one at a time.
*/
#define IMAGING_ARENAS_COUNT 8
extern struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT];
extern struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT+1];
/* Provide a macro that loops through each arena that has been
* statically-allocated. This is necessary to properly handle stats.
*/
#define IMAGING_ARENAS_FOREACH(arena) \
for ((arena) = &ImagingArenas[0]; arena->block_size; ++(arena))
for ((arena) = &ImagingArenas[0]; (arena)->alignment >= 0; ++(arena))
#else
/* In this case we either have the GIL or do not have thread-local storage, in
* which case we will only allocate a single arena.

View File

@ -273,7 +273,7 @@ static uint64_t ImagingArenaIndex = 0;
static IMAGING_TLS uint64_t ImagingArenaThreadIndex = UINT64_MAX;
/* These are the statically-allocated arenas. */
struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT] = {
struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT+1] = {
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 0, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 1, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 2, {0}},
@ -282,7 +282,7 @@ struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT] = {
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 5, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 6, {0}},
{1, IMAGING_ARENA_BLOCK_SIZE, 0, 0, NULL, 0, 0, 0, 0, 0, 7, {0}},
{0}
{-1},
};
/* Get a pointer to the correct arena for this context. In this case where we