Eliminate unnecessary JFREAD()/JFWRITE() macros
This commit is contained in:
2
djpeg.c
2
djpeg.c
@@ -647,7 +647,7 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "%s: memory allocation failure\n", progname);
|
fprintf(stderr, "%s: memory allocation failure\n", progname);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
nbytes = JFREAD(input_file, &inbuffer[insize], INPUT_BUF_SIZE);
|
nbytes = fread(&inbuffer[insize], 1, INPUT_BUF_SIZE, input_file);
|
||||||
if (nbytes < INPUT_BUF_SIZE && ferror(input_file)) {
|
if (nbytes < INPUT_BUF_SIZE && ferror(input_file)) {
|
||||||
if (file_index < argc)
|
if (file_index < argc)
|
||||||
fprintf(stderr, "%s: can't read from %s\n", progname,
|
fprintf(stderr, "%s: can't read from %s\n", progname,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ empty_output_buffer(j_compress_ptr cinfo)
|
|||||||
{
|
{
|
||||||
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
my_dest_ptr dest = (my_dest_ptr)cinfo->dest;
|
||||||
|
|
||||||
if (JFWRITE(dest->outfile, dest->buffer, OUTPUT_BUF_SIZE) !=
|
if (fwrite(dest->buffer, 1, OUTPUT_BUF_SIZE, dest->outfile) !=
|
||||||
(size_t)OUTPUT_BUF_SIZE)
|
(size_t)OUTPUT_BUF_SIZE)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ term_destination(j_compress_ptr cinfo)
|
|||||||
|
|
||||||
/* Write any data remaining in the buffer */
|
/* Write any data remaining in the buffer */
|
||||||
if (datacount > 0) {
|
if (datacount > 0) {
|
||||||
if (JFWRITE(dest->outfile, dest->buffer, datacount) != datacount)
|
if (fwrite(dest->buffer, 1, datacount, dest->outfile) != datacount)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
}
|
}
|
||||||
fflush(dest->outfile);
|
fflush(dest->outfile);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1994-1996, Thomas G. Lane.
|
* Copyright (C) 1994-1996, Thomas G. Lane.
|
||||||
* Modified 2009-2011 by Guido Vollbeding.
|
* Modified 2009-2011 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2013, 2016, D. R. Commander.
|
* Copyright (C) 2013, 2016, 2022, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -104,7 +104,7 @@ fill_input_buffer(j_decompress_ptr cinfo)
|
|||||||
my_src_ptr src = (my_src_ptr)cinfo->src;
|
my_src_ptr src = (my_src_ptr)cinfo->src;
|
||||||
size_t nbytes;
|
size_t nbytes;
|
||||||
|
|
||||||
nbytes = JFREAD(src->infile, src->buffer, INPUT_BUF_SIZE);
|
nbytes = fread(src->buffer, 1, INPUT_BUF_SIZE, src->infile);
|
||||||
|
|
||||||
if (nbytes <= 0) {
|
if (nbytes <= 0) {
|
||||||
if (src->start_of_file) /* Treat empty input file as fatal error */
|
if (src->start_of_file) /* Treat empty input file as fatal error */
|
||||||
|
|||||||
11
jinclude.h
11
jinclude.h
@@ -34,14 +34,3 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* The modules that use fread() and fwrite() always invoke them through
|
|
||||||
* these macros. On some systems you may need to twiddle the argument casts.
|
|
||||||
* CAUTION: argument order is different from underlying functions!
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define JFREAD(file, buf, sizeofbuf) \
|
|
||||||
((size_t)fread((void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
|
||||||
#define JFWRITE(file, buf, sizeofbuf) \
|
|
||||||
((size_t)fwrite((const void *)(buf), (size_t)1, (size_t)(sizeofbuf), (file)))
|
|
||||||
|
|||||||
2
rdbmp.c
2
rdbmp.c
@@ -39,7 +39,7 @@ typedef unsigned char U_CHAR;
|
|||||||
|
|
||||||
|
|
||||||
#define ReadOK(file, buffer, len) \
|
#define ReadOK(file, buffer, len) \
|
||||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
(fread(buffer, 1, len, file) == ((size_t)(len)))
|
||||||
|
|
||||||
static int alpha_index[JPEG_NUMCS] = {
|
static int alpha_index[JPEG_NUMCS] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
||||||
|
|||||||
4
rdgif.c
4
rdgif.c
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||||
* Modified 2019 by Guido Vollbeding.
|
* Modified 2019 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2021, D. R. Commander.
|
* Copyright (C) 2021-2022, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -45,7 +45,7 @@ typedef unsigned char U_CHAR;
|
|||||||
|
|
||||||
|
|
||||||
#define ReadOK(file, buffer, len) \
|
#define ReadOK(file, buffer, len) \
|
||||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
(fread(buffer, 1, len, file) == ((size_t)(len)))
|
||||||
|
|
||||||
|
|
||||||
#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */
|
#define MAXCOLORMAPSIZE 256 /* max # of colors in a GIF colormap */
|
||||||
|
|||||||
2
rdppm.c
2
rdppm.c
@@ -48,7 +48,7 @@ typedef unsigned char U_CHAR;
|
|||||||
|
|
||||||
|
|
||||||
#define ReadOK(file, buffer, len) \
|
#define ReadOK(file, buffer, len) \
|
||||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
(fread(buffer, 1, len, file) == ((size_t)(len)))
|
||||||
|
|
||||||
static int alpha_index[JPEG_NUMCS] = {
|
static int alpha_index[JPEG_NUMCS] = {
|
||||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||||
* Modified 2017 by Guido Vollbeding.
|
* Modified 2017 by Guido Vollbeding.
|
||||||
* libjpeg-turbo Modifications:
|
* libjpeg-turbo Modifications:
|
||||||
* Copyright (C) 2018, 2021, D. R. Commander.
|
* Copyright (C) 2018, 2021-2022, D. R. Commander.
|
||||||
* For conditions of distribution and use, see the accompanying README.ijg
|
* For conditions of distribution and use, see the accompanying README.ijg
|
||||||
* file.
|
* file.
|
||||||
*
|
*
|
||||||
@@ -33,7 +33,7 @@ typedef unsigned char U_CHAR;
|
|||||||
|
|
||||||
|
|
||||||
#define ReadOK(file, buffer, len) \
|
#define ReadOK(file, buffer, len) \
|
||||||
(JFREAD(file, buffer, len) == ((size_t)(len)))
|
(fread(buffer, 1, len, file) == ((size_t)(len)))
|
||||||
|
|
||||||
|
|
||||||
/* Private version of data source object */
|
/* Private version of data source object */
|
||||||
|
|||||||
14
wrbmp.c
14
wrbmp.c
@@ -165,7 +165,7 @@ put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
*outptr++ = 0;
|
*outptr++ = 0;
|
||||||
|
|
||||||
if (!dest->use_inversion_array)
|
if (!dest->use_inversion_array)
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->row_width);
|
fwrite(dest->iobuffer, 1, dest->row_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -200,7 +200,7 @@ put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
*outptr++ = 0;
|
*outptr++ = 0;
|
||||||
|
|
||||||
if (!dest->use_inversion_array)
|
if (!dest->use_inversion_array)
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->row_width);
|
fwrite(dest->iobuffer, 1, dest->row_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,9 +281,9 @@ write_bmp_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
|
|||||||
PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */
|
PUT_2B(bmpinfoheader, 32, cmap_entries); /* biClrUsed */
|
||||||
/* we leave biClrImportant = 0 */
|
/* we leave biClrImportant = 0 */
|
||||||
|
|
||||||
if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t)14)
|
if (fwrite(bmpfileheader, 1, 14, dest->pub.output_file) != (size_t)14)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
if (JFWRITE(dest->pub.output_file, bmpinfoheader, 40) != (size_t)40)
|
if (fwrite(bmpinfoheader, 1, 40, dest->pub.output_file) != (size_t)40)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
|
|
||||||
if (cmap_entries > 0)
|
if (cmap_entries > 0)
|
||||||
@@ -342,9 +342,9 @@ write_os2_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
|
|||||||
PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */
|
PUT_2B(bmpcoreheader, 8, 1); /* bcPlanes - must be 1 */
|
||||||
PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */
|
PUT_2B(bmpcoreheader, 10, bits_per_pixel); /* bcBitCount */
|
||||||
|
|
||||||
if (JFWRITE(dest->pub.output_file, bmpfileheader, 14) != (size_t)14)
|
if (fwrite(bmpfileheader, 1, 14, dest->pub.output_file) != (size_t)14)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
if (JFWRITE(dest->pub.output_file, bmpcoreheader, 12) != (size_t)12)
|
if (fwrite(bmpcoreheader, 1, 12, dest->pub.output_file) != (size_t)12)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
|
|
||||||
if (cmap_entries > 0)
|
if (cmap_entries > 0)
|
||||||
@@ -456,7 +456,7 @@ finish_output_bmp(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
|
|||||||
((j_common_ptr)cinfo, dest->whole_image, row - 1, (JDIMENSION)1,
|
((j_common_ptr)cinfo, dest->whole_image, row - 1, (JDIMENSION)1,
|
||||||
FALSE);
|
FALSE);
|
||||||
data_ptr = image_ptr[0];
|
data_ptr = image_ptr[0];
|
||||||
(void)JFWRITE(outfile, data_ptr, dest->row_width);
|
fwrite(data_ptr, 1, dest->row_width, outfile);
|
||||||
}
|
}
|
||||||
if (progress != NULL)
|
if (progress != NULL)
|
||||||
progress->completed_extra_passes++;
|
progress->completed_extra_passes++;
|
||||||
|
|||||||
4
wrgif.c
4
wrgif.c
@@ -114,8 +114,8 @@ flush_packet(gif_dest_ptr dinfo)
|
|||||||
{
|
{
|
||||||
if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */
|
if (dinfo->bytesinpkt > 0) { /* never write zero-length packet */
|
||||||
dinfo->packetbuf[0] = (char)dinfo->bytesinpkt++;
|
dinfo->packetbuf[0] = (char)dinfo->bytesinpkt++;
|
||||||
if (JFWRITE(dinfo->pub.output_file, dinfo->packetbuf, dinfo->bytesinpkt) !=
|
if (fwrite(dinfo->packetbuf, 1, dinfo->bytesinpkt,
|
||||||
(size_t)dinfo->bytesinpkt)
|
dinfo->pub.output_file) != (size_t)dinfo->bytesinpkt)
|
||||||
ERREXIT(dinfo->cinfo, JERR_FILE_WRITE);
|
ERREXIT(dinfo->cinfo, JERR_FILE_WRITE);
|
||||||
dinfo->bytesinpkt = 0;
|
dinfo->bytesinpkt = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
12
wrppm.c
12
wrppm.c
@@ -92,7 +92,7 @@ put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
{
|
{
|
||||||
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
|
ppm_dest_ptr dest = (ppm_dest_ptr)dinfo;
|
||||||
|
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ copy_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
PUTPPMSAMPLE(bufferptr, *ptr++);
|
PUTPPMSAMPLE(bufferptr, *ptr++);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +149,7 @@ put_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, JDIMENSION rows_supplied)
|
|||||||
PUTPPMSAMPLE(bufferptr, ptr[bindex]);
|
PUTPPMSAMPLE(bufferptr, ptr[bindex]);
|
||||||
ptr += ps;
|
ptr += ps;
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ put_cmyk(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
PUTPPMSAMPLE(bufferptr, g);
|
PUTPPMSAMPLE(bufferptr, g);
|
||||||
PUTPPMSAMPLE(bufferptr, b);
|
PUTPPMSAMPLE(bufferptr, b);
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ put_demapped_rgb(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
PUTPPMSAMPLE(bufferptr, color_map1[pixval]);
|
PUTPPMSAMPLE(bufferptr, color_map1[pixval]);
|
||||||
PUTPPMSAMPLE(bufferptr, color_map2[pixval]);
|
PUTPPMSAMPLE(bufferptr, color_map2[pixval]);
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ put_demapped_gray(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
for (col = cinfo->output_width; col > 0; col--) {
|
for (col = cinfo->output_width; col > 0; col--) {
|
||||||
PUTPPMSAMPLE(bufferptr, color_map[*ptr++]);
|
PUTPPMSAMPLE(bufferptr, color_map[*ptr++]);
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ write_header(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JFWRITE(dinfo->output_file, targaheader, 18) != (size_t)18)
|
if (fwrite(targaheader, 1, 18, dinfo->output_file) != (size_t)18)
|
||||||
ERREXIT(cinfo, JERR_FILE_WRITE);
|
ERREXIT(cinfo, JERR_FILE_WRITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +107,7 @@ put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
outptr[2] = inptr[0];
|
outptr[2] = inptr[0];
|
||||||
inptr += 3, outptr += 3;
|
inptr += 3, outptr += 3;
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
METHODDEF(void)
|
METHODDEF(void)
|
||||||
@@ -122,7 +122,7 @@ put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
inptr = dest->pub.buffer[0];
|
inptr = dest->pub.buffer[0];
|
||||||
outptr = dest->iobuffer;
|
outptr = dest->iobuffer;
|
||||||
memcpy(outptr, inptr, cinfo->output_width);
|
memcpy(outptr, inptr, cinfo->output_width);
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ put_demapped_gray(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
|
|||||||
for (col = cinfo->output_width; col > 0; col--) {
|
for (col = cinfo->output_width; col > 0; col--) {
|
||||||
*outptr++ = color_map0[*inptr++];
|
*outptr++ = color_map0[*inptr++];
|
||||||
}
|
}
|
||||||
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
|
fwrite(dest->iobuffer, 1, dest->buffer_width, dest->pub.output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user