From 7d2ea7665ffde4aba58ba8a7a719d9d4413ee442 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 14 Feb 2025 19:05:39 +0100 Subject: [PATCH] Fix iterations through arenas --- src/libImaging/Imaging.h | 4 ++-- src/libImaging/Storage.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libImaging/Imaging.h b/src/libImaging/Imaging.h index 6bb93d540..9fa79f467 100644 --- a/src/libImaging/Imaging.h +++ b/src/libImaging/Imaging.h @@ -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. diff --git a/src/libImaging/Storage.c b/src/libImaging/Storage.c index 16f07816a..40b48257c 100644 --- a/src/libImaging/Storage.c +++ b/src/libImaging/Storage.c @@ -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