mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36: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);
|
||||||
|
|
||||||
|
|
|
@ -215,11 +215,21 @@ ImagingNewPrologueSubtype(const char *mode, int xsize, int ysize, int size)
|
||||||
exceptions on platforms where calloc(0, x) returns NULL) */
|
exceptions on platforms where calloc(0, x) returns NULL) */
|
||||||
im->image = (char **) calloc((ysize > 0) ? ysize : 1, sizeof(void *));
|
im->image = (char **) calloc((ysize > 0) ? ysize : 1, sizeof(void *));
|
||||||
|
|
||||||
if (!im->image) {
|
if ( ! im->image) {
|
||||||
free(im);
|
free(im);
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -312,9 +308,8 @@ ImagingNewArray(const char *mode, int xsize, int ysize)
|
||||||
ImagingDelete(im);
|
ImagingDelete(im);
|
||||||
return (Imaging) ImagingError_MemoryError();
|
return (Imaging) ImagingError_MemoryError();
|
||||||
}
|
}
|
||||||
|
|
||||||
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