Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,6 @@ static PyObject *
_transform(ImagingObject *self, PyObject *args) {
static const char *wrong_length = "wrong number of matrix entries";

Imaging imOut;
Py_ssize_t n;
double *a;

Expand Down
8 changes: 3 additions & 5 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef struct {
PyObject_HEAD int (*decode)(
Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes
);
int (*cleanup)(ImagingCodecState state);
void (*cleanup)(ImagingCodecState state);
struct ImagingCodecStateInstance state;
Imaging im;
PyObject *lock;
Expand Down Expand Up @@ -141,13 +141,11 @@ _decode(ImagingDecoderObject *decoder, PyObject *args) {

static PyObject *
_decode_cleanup(ImagingDecoderObject *decoder, PyObject *args) {
int status = 0;

if (decoder->cleanup) {
status = decoder->cleanup(&decoder->state);
decoder->cleanup(&decoder->state);
}

return Py_BuildValue("i", status);
Py_RETURN_NONE;
}

extern Imaging
Expand Down
8 changes: 3 additions & 5 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct {
PyObject_HEAD int (*encode)(
Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes
);
int (*cleanup)(ImagingCodecState state);
void (*cleanup)(ImagingCodecState state);
struct ImagingCodecStateInstance state;
Imaging im;
PyObject *lock;
Expand Down Expand Up @@ -108,13 +108,11 @@ _dealloc(ImagingEncoderObject *encoder) {

static PyObject *
_encode_cleanup(ImagingEncoderObject *encoder, PyObject *args) {
int status = 0;

if (encoder->cleanup) {
status = encoder->cleanup(&encoder->state);
encoder->cleanup(&encoder->state);
}

return Py_BuildValue("i", status);
Py_RETURN_NONE;
}

static PyObject *
Expand Down
10 changes: 5 additions & 5 deletions src/libImaging/Imaging.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ ImagingHexDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t
#ifdef HAVE_LIBJPEG
extern int
ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes);
extern int
extern void
ImagingJpegDecodeCleanup(ImagingCodecState state);
extern int
ImagingJpegUseJCSExtensions(void);
Expand All @@ -631,11 +631,11 @@ extern int
ImagingJpeg2KDecode(
Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes
);
extern int
extern void
ImagingJpeg2KDecodeCleanup(ImagingCodecState state);
extern int
ImagingJpeg2KEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes);
extern int
extern void
ImagingJpeg2KEncodeCleanup(ImagingCodecState state);
#endif
#ifdef HAVE_LIBTIFF
Expand Down Expand Up @@ -683,11 +683,11 @@ ImagingXbmEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes);
#ifdef HAVE_LIBZ
extern int
ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes);
extern int
extern void
ImagingZipDecodeCleanup(ImagingCodecState state);
extern int
ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes);
extern int
extern void
ImagingZipEncodeCleanup(ImagingCodecState state);
#endif

Expand Down
4 changes: 1 addition & 3 deletions src/libImaging/Jpeg2KDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ ImagingJpeg2KDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t
/* Cleanup */
/* -------------------------------------------------------------------- */

int
void
ImagingJpeg2KDecodeCleanup(ImagingCodecState state) {
JPEG2KDECODESTATE *context = (JPEG2KDECODESTATE *)state->context;

Expand All @@ -970,8 +970,6 @@ ImagingJpeg2KDecodeCleanup(ImagingCodecState state) {
}

context->error_msg = NULL;

return -1;
}

const char *
Expand Down
4 changes: 1 addition & 3 deletions src/libImaging/Jpeg2KEncode.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ ImagingJpeg2KEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes)
/* Cleanup */
/* -------------------------------------------------------------------- */

int
void
ImagingJpeg2KEncodeCleanup(ImagingCodecState state) {
JPEG2KENCODESTATE *context = (JPEG2KENCODESTATE *)state->context;

Expand All @@ -656,8 +656,6 @@ ImagingJpeg2KEncodeCleanup(ImagingCodecState state) {

context->error_msg = NULL;
context->comment = NULL;

return -1;
}

#endif /* HAVE_OPENJPEG */
3 changes: 1 addition & 2 deletions src/libImaging/JpegDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t by
/* Cleanup */
/* -------------------------------------------------------------------- */

int
void
ImagingJpegDecodeCleanup(ImagingCodecState state) {
/* called to free the decompression engine when the decode terminates
due to a corrupt or truncated image
Expand All @@ -300,7 +300,6 @@ ImagingJpegDecodeCleanup(ImagingCodecState state) {

/* Clean up */
jpeg_destroy_decompress(&context->cinfo);
return -1;
}

#endif
5 changes: 2 additions & 3 deletions src/libImaging/TiffDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,13 +740,13 @@ ImagingLibTiffSetField(ImagingCodecState state, ttag_t tag, ...) {
return status;
}

int
void
ImagingLibTiffEncodeCleanup(ImagingCodecState state) {
TIFFSTATE *clientstate = (TIFFSTATE *)state->context;
TIFF *tiff = clientstate->tiff;

if (!tiff) {
return 0;
return;
}
// TIFFClose in libtiff calls tif_closeproc and TIFFCleanup
if (clientstate->fp) {
Expand All @@ -759,7 +759,6 @@ ImagingLibTiffEncodeCleanup(ImagingCodecState state) {
TIFFClose(tiff);
}
clientstate->tiff = NULL;
return 0;
}

int
Expand Down
2 changes: 1 addition & 1 deletion src/libImaging/TiffDecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern int
ImagingLibTiffInit(ImagingCodecState state, int fp, uint32_t offset);
extern int
ImagingLibTiffEncodeInit(ImagingCodecState state, char *filename, int fp);
extern int
extern void
ImagingLibTiffEncodeCleanup(ImagingCodecState state);
extern int
ImagingLibTiffMergeFieldInfo(
Expand Down
3 changes: 1 addition & 2 deletions src/libImaging/ZipDecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8 *buf, Py_ssize_t byt
return bytes; /* consumed all of it */
}

int
void
ImagingZipDecodeCleanup(ImagingCodecState state) {
/* called to free the decompression engine when the decode terminates
due to a corrupt or truncated image
Expand All @@ -296,7 +296,6 @@ ImagingZipDecodeCleanup(ImagingCodecState state) {
free(context->previous);
context->previous = NULL;
}
return -1;
}

#endif
4 changes: 1 addition & 3 deletions src/libImaging/ZipEncode.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,16 +350,14 @@ ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8 *buf, int bytes) {
/* Cleanup */
/* -------------------------------------------------------------------- */

int
void
ImagingZipEncodeCleanup(ImagingCodecState state) {
ZIPSTATE *context = (ZIPSTATE *)state->context;

if (context->dictionary) {
free(context->dictionary);
context->dictionary = NULL;
}

return -1;
}

const char *
Expand Down
Loading