mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
move ImagingNewEpilogue functionality to ImagingNewPrologueSubtype
doublechecked: no im->image or im->image8 or im->image32 access between ImagingNewPrologue and ImagingNewEpilogue anywhere
This commit is contained in:
parent
fd9cf03d01
commit
ab92adf7c9
|
@ -172,7 +172,6 @@ extern Imaging ImagingNewPrologue(const char *mode,
|
||||||
extern Imaging ImagingNewPrologueSubtype(const char *mode,
|
extern Imaging ImagingNewPrologueSubtype(const char *mode,
|
||||||
int xsize, int ysize,
|
int xsize, int ysize,
|
||||||
int structure_size);
|
int structure_size);
|
||||||
extern void ImagingNewEpilogue(Imaging im);
|
|
||||||
|
|
||||||
extern void ImagingCopyInfo(Imaging destination, Imaging source);
|
extern void ImagingCopyInfo(Imaging destination, Imaging source);
|
||||||
|
|
||||||
|
|
|
@ -220,6 +220,16 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size)
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return (Imaging) ImagingError_MemoryError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize alias pointers to pixel data. */
|
||||||
|
switch (im->pixelsize) {
|
||||||
|
case 1: case 2: case 3:
|
||||||
|
im->image8 = (UINT8 **) im->image;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
im->image32 = (INT32 **) im->image;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ImagingNewCount++;
|
ImagingNewCount++;
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
|
@ -232,20 +242,6 @@ ImagingNewPrologue(const char *mode, int xsize, int ysize)
|
||||||
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance));
|
mode, xsize, ysize, sizeof(struct ImagingMemoryInstance));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ImagingNewEpilogue(Imaging im)
|
|
||||||
{
|
|
||||||
/* Initialize alias pointers to pixel data. */
|
|
||||||
switch (im->pixelsize) {
|
|
||||||
case 1: case 2: case 3:
|
|
||||||
im->image8 = (UINT8 **) im->image;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
im->image32 = (INT32 **) im->image;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ImagingDelete(Imaging im)
|
ImagingDelete(Imaging im)
|
||||||
{
|
{
|
||||||
|
@ -314,7 +310,6 @@ ImagingNewArray(const char *mode, int xsize, int ysize)
|
||||||
}
|
}
|
||||||
|
|
||||||
im->destroy = ImagingDestroyArray;
|
im->destroy = ImagingDestroyArray;
|
||||||
ImagingNewEpilogue(im);
|
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +333,9 @@ ImagingNewBlock(const char *mode, int xsize, int ysize)
|
||||||
Py_ssize_t y, i;
|
Py_ssize_t y, i;
|
||||||
|
|
||||||
im = ImagingNewPrologue(mode, xsize, ysize);
|
im = ImagingNewPrologue(mode, xsize, ysize);
|
||||||
if (!im)
|
if ( ! im) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* We shouldn't overflow, since the threshold defined
|
/* We shouldn't overflow, since the threshold defined
|
||||||
below says that we're only going to allocate max 4M
|
below says that we're only going to allocate max 4M
|
||||||
|
@ -372,7 +368,6 @@ ImagingNewBlock(const char *mode, int xsize, int ysize)
|
||||||
}
|
}
|
||||||
|
|
||||||
im->destroy = ImagingDestroyBlock;
|
im->destroy = ImagingDestroyBlock;
|
||||||
ImagingNewEpilogue(im);
|
|
||||||
|
|
||||||
return im;
|
return im;
|
||||||
}
|
}
|
||||||
|
|
7
map.c
7
map.c
|
@ -229,8 +229,6 @@ mapping_readimage(ImagingMapperObject* mapper, PyObject* args)
|
||||||
|
|
||||||
im->destroy = ImagingDestroyMap;
|
im->destroy = ImagingDestroyMap;
|
||||||
|
|
||||||
ImagingNewEpilogue(im);
|
|
||||||
|
|
||||||
mapper->offset += size;
|
mapper->offset += size;
|
||||||
|
|
||||||
return PyImagingNew(im);
|
return PyImagingNew(im);
|
||||||
|
@ -367,8 +365,7 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
||||||
}
|
}
|
||||||
|
|
||||||
im = ImagingNewPrologueSubtype(
|
im = ImagingNewPrologueSubtype(
|
||||||
mode, xsize, ysize, sizeof(ImagingBufferInstance)
|
mode, xsize, ysize, sizeof(ImagingBufferInstance));
|
||||||
);
|
|
||||||
if (!im)
|
if (!im)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -386,8 +383,6 @@ PyImaging_MapBuffer(PyObject* self, PyObject* args)
|
||||||
((ImagingBufferInstance*) im)->target = target;
|
((ImagingBufferInstance*) im)->target = target;
|
||||||
((ImagingBufferInstance*) im)->view = view;
|
((ImagingBufferInstance*) im)->view = view;
|
||||||
|
|
||||||
ImagingNewEpilogue(im);
|
|
||||||
|
|
||||||
return PyImagingNew(im);
|
return PyImagingNew(im);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user