mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-07 06:33:10 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
9b130e6d6c
commit
cff21412c5
|
@ -216,7 +216,8 @@ extern struct ImagingMemoryArena ImagingDefaultArena;
|
||||||
for ((arena) = &ImagingDefaultArena; (arena); (arena) = NULL)
|
for ((arena) = &ImagingDefaultArena; (arena); (arena) = NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ImagingMemoryArena ImagingGetArena(void);
|
ImagingMemoryArena
|
||||||
|
ImagingGetArena(void);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
ImagingMemorySetBlocksMax(ImagingMemoryArena arena, int blocks_max);
|
ImagingMemorySetBlocksMax(ImagingMemoryArena arena, int blocks_max);
|
||||||
|
|
|
@ -289,9 +289,11 @@ struct ImagingMemoryArena ImagingArenas[IMAGING_ARENAS_COUNT] = {
|
||||||
* are using a round-robin approach to the statically allocated arenas, we will
|
* are using a round-robin approach to the statically allocated arenas, we will
|
||||||
* return the arena that is assigned to the thread on first use.
|
* return the arena that is assigned to the thread on first use.
|
||||||
*/
|
*/
|
||||||
ImagingMemoryArena ImagingGetArena(void) {
|
ImagingMemoryArena
|
||||||
|
ImagingGetArena(void) {
|
||||||
if (ImagingArenaThreadIndex == UINT64_MAX) {
|
if (ImagingArenaThreadIndex == UINT64_MAX) {
|
||||||
ImagingArenaThreadIndex = _Py_atomic_add_uint64(&ImagingArenaIndex, 1) % IMAGING_ARENAS_COUNT;
|
ImagingArenaThreadIndex =
|
||||||
|
_Py_atomic_add_uint64(&ImagingArenaIndex, 1) % IMAGING_ARENAS_COUNT;
|
||||||
}
|
}
|
||||||
return &ImagingArenas[ImagingArenaThreadIndex];
|
return &ImagingArenas[ImagingArenaThreadIndex];
|
||||||
}
|
}
|
||||||
|
@ -299,7 +301,8 @@ ImagingMemoryArena ImagingGetArena(void) {
|
||||||
/* Return the arena associated with the given image. In this case the index of
|
/* Return the arena associated with the given image. In this case the index of
|
||||||
* the arena is stored on the image itself.
|
* the arena is stored on the image itself.
|
||||||
*/
|
*/
|
||||||
ImagingMemoryArena ImagingGetArenaFromImaging(Imaging im) {
|
ImagingMemoryArena
|
||||||
|
ImagingGetArenaFromImaging(Imaging im) {
|
||||||
int arenaindex = im->arenaindex;
|
int arenaindex = im->arenaindex;
|
||||||
assert(arenaindex >= 0 && arenaindex < IMAGING_ARENAS_COUNT);
|
assert(arenaindex >= 0 && arenaindex < IMAGING_ARENAS_COUNT);
|
||||||
return &ImagingArenas[arenaindex];
|
return &ImagingArenas[arenaindex];
|
||||||
|
@ -309,7 +312,8 @@ ImagingMemoryArena ImagingGetArenaFromImaging(Imaging im) {
|
||||||
* is necessary in order to return the blocks to the correct arena when the
|
* is necessary in order to return the blocks to the correct arena when the
|
||||||
* image is destroyed.
|
* image is destroyed.
|
||||||
*/
|
*/
|
||||||
static void ImagingSetArenaOnImaging(Imaging im, ImagingMemoryArena arena) {
|
static void
|
||||||
|
ImagingSetArenaOnImaging(Imaging im, ImagingMemoryArena arena) {
|
||||||
im->arenaindex = arena->index;
|
im->arenaindex = arena->index;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -340,7 +344,8 @@ struct ImagingMemoryArena ImagingDefaultArena = {
|
||||||
* either have the GIL or we do not have TLS, we will return only the default
|
* either have the GIL or we do not have TLS, we will return only the default
|
||||||
* arena.
|
* arena.
|
||||||
*/
|
*/
|
||||||
ImagingMemoryArena ImagingGetArena(void) {
|
ImagingMemoryArena
|
||||||
|
ImagingGetArena(void) {
|
||||||
return &ImagingDefaultArena;
|
return &ImagingDefaultArena;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,9 +594,7 @@ ImagingNewInternal(const char *mode, int xsize, int ysize, int dirty) {
|
||||||
ImagingSetArenaOnImaging(im, arena);
|
ImagingSetArenaOnImaging(im, arena);
|
||||||
|
|
||||||
MUTEX_LOCK(&arena->mutex);
|
MUTEX_LOCK(&arena->mutex);
|
||||||
Imaging tmp = ImagingAllocateArray(
|
Imaging tmp = ImagingAllocateArray(im, arena, dirty, arena->block_size);
|
||||||
im, arena, dirty, arena->block_size
|
|
||||||
);
|
|
||||||
MUTEX_UNLOCK(&arena->mutex);
|
MUTEX_UNLOCK(&arena->mutex);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
return im;
|
return im;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user