Skip to content

Commit

Permalink
Fix iterations through arenas
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Feb 14, 2025
1 parent 19154a5 commit 7d2ea76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/libImaging/Imaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/libImaging/Storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}},
Expand All @@ -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
Expand Down

0 comments on commit 7d2ea76

Please sign in to comment.