Eliminate non-ANSI C compatibility macros

libjpeg-turbo has never supported non-ANSI C compilers.  Per the spec,
ANSI C compilers must have locale.h, stddef.h, stdlib.h, memset(),
memcpy(), unsigned char, and unsigned short.  They must also handle
undefined structures.
This commit is contained in:
DRC
2022-01-06 09:17:30 -06:00
parent a7f0244e9b
commit 172972394a
41 changed files with 122 additions and 326 deletions

View File

@@ -406,34 +406,6 @@ if(MSVC)
endif() endif()
if(UNIX) if(UNIX)
# Check for headers
check_include_files(locale.h HAVE_LOCALE_H)
check_include_files(stddef.h HAVE_STDDEF_H)
check_include_files(stdlib.h HAVE_STDLIB_H)
check_include_files(sys/types.h NEED_SYS_TYPES_H)
# Check for functions
include(CheckSymbolExists)
check_symbol_exists(memset string.h HAVE_MEMSET)
check_symbol_exists(memcpy string.h HAVE_MEMCPY)
if(NOT HAVE_MEMSET AND NOT HAVE_MEMCPY)
set(NEED_BSD_STRINGS 1)
endif()
# Check for types
check_type_size("unsigned char" UNSIGNED_CHAR)
check_type_size("unsigned short" UNSIGNED_SHORT)
# Check for compiler features
check_c_source_compiles("int main(void) { typedef struct undefined_structure *undef_struct_ptr; undef_struct_ptr ptr = 0; return ptr != 0; }"
INCOMPLETE_TYPES)
if(INCOMPLETE_TYPES)
message(STATUS "Compiler supports pointers to undefined structures.")
else()
set(INCOMPLETE_TYPES_BROKEN 1)
message(STATUS "Compiler does not support pointers to undefined structures.")
endif()
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
set(RIGHT_SHIFT_IS_UNSIGNED 0) set(RIGHT_SHIFT_IS_UNSIGNED 0)
else() else()

View File

@@ -91,7 +91,7 @@ best of our understanding.
The Modified (3-clause) BSD License The Modified (3-clause) BSD License
=================================== ===================================
Copyright (C)2009-2021 D. R. Commander. All Rights Reserved.<br> Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.<br>
Copyright (C)2015 Viktor Szathmáry. All Rights Reserved. Copyright (C)2015 Viktor Szathmáry. All Rights Reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without

View File

@@ -34,11 +34,6 @@
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "jconfigint.h" #include "jconfigint.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void *malloc(size_t size);
extern void free(void *ptr);
#endif
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */
#ifdef __MWERKS__ #ifdef __MWERKS__
#include <SIOUX.h> /* Metrowerks needs this */ #include <SIOUX.h> /* Metrowerks needs this */

View File

@@ -32,10 +32,6 @@
#include "jversion.h" /* for version message */ #include "jversion.h" /* for version message */
#include "jconfigint.h" #include "jconfigint.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare free() */
extern void free(void *ptr);
#endif
#include <ctype.h> /* to declare isprint() */ #include <ctype.h> /* to declare isprint() */
#ifdef USE_CCOMMAND /* command-line reader for Macintosh */ #ifdef USE_CCOMMAND /* command-line reader for Macintosh */

View File

@@ -4,8 +4,8 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* Modified 2003-2010 by Guido Vollbeding. * Modified 2003-2010 by Guido Vollbeding.
* It was modified by The libjpeg-turbo Project to include only code relevant * libjpeg-turbo Modifications:
* to libjpeg-turbo. * Copyright (C) 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.
* *
@@ -52,7 +52,7 @@ jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
{ {
struct jpeg_error_mgr *err = cinfo->err; struct jpeg_error_mgr *err = cinfo->err;
void *client_data = cinfo->client_data; /* ignore Purify complaint here */ void *client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, sizeof(struct jpeg_compress_struct)); memset(cinfo, 0, sizeof(struct jpeg_compress_struct));
cinfo->err = err; cinfo->err = err;
cinfo->client_data = client_data; cinfo->client_data = client_data;
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Developed 1997-2009 by Guido Vollbeding. * Developed 1997-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015, 2018, 2021, D. R. Commander. * Copyright (C) 2015, 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.
* *
@@ -338,14 +338,14 @@ emit_restart(j_compress_ptr cinfo, int restart_num)
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
/* DC needs no table for refinement scan */ /* DC needs no table for refinement scan */
if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) { if (cinfo->progressive_mode == 0 || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS); memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
/* Reset DC predictions to 0 */ /* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0; entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0; entropy->dc_context[ci] = 0;
} }
/* AC needs no table when not present */ /* AC needs no table when not present */
if (cinfo->progressive_mode == 0 || cinfo->Se) { if (cinfo->progressive_mode == 0 || cinfo->Se) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS); memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
} }
} }
@@ -867,7 +867,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
if (entropy->dc_stats[tbl] == NULL) if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS); ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS); memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
/* Initialize DC predictions to 0 */ /* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0; entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0; entropy->dc_context[ci] = 0;
@@ -880,7 +880,7 @@ start_pass(j_compress_ptr cinfo, boolean gather_statistics)
if (entropy->ac_stats[tbl] == NULL) if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS); ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS); memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
#ifdef CALCULATE_SPECTRAL_CONDITIONING #ifdef CALCULATE_SPECTRAL_CONDITIONING
if (cinfo->progressive_mode) if (cinfo->progressive_mode)
/* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */ /* Section G.1.3.2: Set appropriate arithmetic conditioning value Kx */

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, 2014-2016, 2018-2021, D. R. Commander. * Copyright (C) 2009-2011, 2014-2016, 2018-2022, D. R. Commander.
* Copyright (C) 2015, Matthieu Darbois. * Copyright (C) 2015, Matthieu Darbois.
* Copyright (C) 2018, Matthias Räncker. * Copyright (C) 2018, Matthias Räncker.
* Copyright (C) 2020, Arm Limited. * Copyright (C) 2020, Arm Limited.
@@ -200,12 +200,12 @@ start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
entropy->dc_count_ptrs[dctbl] = (long *) entropy->dc_count_ptrs[dctbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
257 * sizeof(long)); 257 * sizeof(long));
MEMZERO(entropy->dc_count_ptrs[dctbl], 257 * sizeof(long)); memset(entropy->dc_count_ptrs[dctbl], 0, 257 * sizeof(long));
if (entropy->ac_count_ptrs[actbl] == NULL) if (entropy->ac_count_ptrs[actbl] == NULL)
entropy->ac_count_ptrs[actbl] = (long *) entropy->ac_count_ptrs[actbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
257 * sizeof(long)); 257 * sizeof(long));
MEMZERO(entropy->ac_count_ptrs[actbl], 257 * sizeof(long)); memset(entropy->ac_count_ptrs[actbl], 0, 257 * sizeof(long));
#endif #endif
} else { } else {
/* Compute derived values for Huffman tables */ /* Compute derived values for Huffman tables */
@@ -315,8 +315,8 @@ jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno,
* this lets us detect duplicate VAL entries here, and later * this lets us detect duplicate VAL entries here, and later
* allows emit_bits to detect any attempt to emit such symbols. * allows emit_bits to detect any attempt to emit such symbols.
*/ */
MEMZERO(dtbl->ehufco, sizeof(dtbl->ehufco)); memset(dtbl->ehufco, 0, sizeof(dtbl->ehufco));
MEMZERO(dtbl->ehufsi, sizeof(dtbl->ehufsi)); memset(dtbl->ehufsi, 0, sizeof(dtbl->ehufsi));
/* This is also a convenient place to check for out-of-range /* This is also a convenient place to check for out-of-range
* and duplicated VAL entries. We allow 0..255 for AC symbols * and duplicated VAL entries. We allow 0..255 for AC symbols
@@ -478,7 +478,7 @@ dump_buffer(working_state *state)
buffer = _buffer; \ buffer = _buffer; \
while (bytes > 0) { \ while (bytes > 0) { \
bytestocopy = MIN(bytes, state->free_in_buffer); \ bytestocopy = MIN(bytes, state->free_in_buffer); \
MEMCOPY(state->next_output_byte, buffer, bytestocopy); \ memcpy(state->next_output_byte, buffer, bytestocopy); \
state->next_output_byte += bytestocopy; \ state->next_output_byte += bytestocopy; \
buffer += bytestocopy; \ buffer += bytestocopy; \
state->free_in_buffer -= bytestocopy; \ state->free_in_buffer -= bytestocopy; \
@@ -941,8 +941,8 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
/* This algorithm is explained in section K.2 of the JPEG standard */ /* This algorithm is explained in section K.2 of the JPEG standard */
MEMZERO(bits, sizeof(bits)); memset(bits, 0, sizeof(bits));
MEMZERO(codesize, sizeof(codesize)); memset(codesize, 0, sizeof(codesize));
for (i = 0; i < 257; i++) for (i = 0; i < 257; i++)
others[i] = -1; /* init links to empty */ others[i] = -1; /* init links to empty */
@@ -1044,7 +1044,7 @@ jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
bits[i]--; bits[i]--;
/* Return final symbol counts (only for lengths 0..16) */ /* Return final symbol counts (only for lengths 0..16) */
MEMCOPY(htbl->bits, bits, sizeof(htbl->bits)); memcpy(htbl->bits, bits, sizeof(htbl->bits));
/* Return a list of the symbols sorted by code length */ /* Return a list of the symbols sorted by code length */
/* It's not real clear to me why we don't need to consider the codelength /* It's not real clear to me why we don't need to consider the codelength
@@ -1083,8 +1083,8 @@ finish_pass_gather(j_compress_ptr cinfo)
/* It's important not to apply jpeg_gen_optimal_table more than once /* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts! * per table, because it clobbers the input frequency counts!
*/ */
MEMZERO(did_dc, sizeof(did_dc)); memset(did_dc, 0, sizeof(did_dc));
MEMZERO(did_ac, sizeof(did_ac)); memset(did_ac, 0, sizeof(did_ac));
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];

View File

@@ -32,37 +32,6 @@
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */ #define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
/* Define to 1 if you have the <locale.h> header file. */
#cmakedefine HAVE_LOCALE_H 1
/* Define to 1 if you have the <stddef.h> header file. */
#cmakedefine HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H 1
/* Define if you need to include <sys/types.h> to get size_t. */
#cmakedefine NEED_SYS_TYPES_H 1
/* Define if you have BSD-like bzero and bcopy in <strings.h> rather than
memset/memcpy in <string.h>. */
#cmakedefine NEED_BSD_STRINGS 1
/* Define to 1 if the system has the type `unsigned char'. */
#cmakedefine HAVE_UNSIGNED_CHAR 1
/* Define to 1 if the system has the type `unsigned short'. */
#cmakedefine HAVE_UNSIGNED_SHORT 1
/* Compiler does not support pointers to undefined structures. */
#cmakedefine INCOMPLETE_TYPES_BROKEN 1
/* Define if your (broken) compiler shifts signed values as if they were /* Define if your (broken) compiler shifts signed values as if they were
unsigned. */ unsigned. */
#cmakedefine RIGHT_SHIFT_IS_UNSIGNED 1 #cmakedefine RIGHT_SHIFT_IS_UNSIGNED 1
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */

View File

@@ -26,50 +26,6 @@
* #define the symbol if yes, #undef it if no. * #define the symbol if yes, #undef it if no.
*/ */
/* Does your compiler support the declaration "unsigned char" ?
* How about "unsigned short" ?
*/
#define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT
/* Define "void" as "char" if your compiler doesn't know about type void.
* NOTE: be sure to define void such that "void *" represents the most general
* pointer type, e.g., that returned by malloc().
*/
/* #define void char */
/* Define "const" as empty if your compiler doesn't know the "const" keyword.
*/
/* #define const */
/* Define this if your system has an ANSI-conforming <stddef.h> file.
*/
#define HAVE_STDDEF_H
/* Define this if your system has an ANSI-conforming <stdlib.h> file.
*/
#define HAVE_STDLIB_H
/* Define this if your system does not have an ANSI/SysV <string.h>,
* but does have a BSD-style <strings.h>.
*/
#undef NEED_BSD_STRINGS
/* Define this if your system does not provide typedef size_t in any of the
* ANSI-standard places (stddef.h, stdlib.h, or stdio.h), but places it in
* <sys/types.h> instead.
*/
#undef NEED_SYS_TYPES_H
/* Although a real ANSI C compiler can deal perfectly well with pointers to
* unspecified structures (see "incomplete types" in the spec), a few pre-ANSI
* and pseudo-ANSI compilers get confused. To keep one of these bozos happy,
* define INCOMPLETE_TYPES_BROKEN. This is not recommended unless you
* actually get "missing structure definition" warnings or errors while
* compiling the JPEG code.
*/
#undef INCOMPLETE_TYPES_BROKEN
/* Define "boolean" as unsigned char, not int, on Windows systems. /* Define "boolean" as unsigned char, not int, on Windows systems.
*/ */
#ifdef _WIN32 #ifdef _WIN32

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1995-1997, Thomas G. Lane. * Copyright (C) 1995-1997, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2011, 2015, 2018, 2021, D. R. Commander. * Copyright (C) 2011, 2015, 2018, 2021-2022, D. R. Commander.
* Copyright (C) 2016, 2018, Matthieu Darbois. * Copyright (C) 2016, 2018, Matthieu Darbois.
* Copyright (C) 2020, Arm Limited. * Copyright (C) 2020, Arm Limited.
* Copyright (C) 2021, Alex Richardson. * Copyright (C) 2021, Alex Richardson.
@@ -275,7 +275,7 @@ start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
entropy->count_ptrs[tbl] = (long *) entropy->count_ptrs[tbl] = (long *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
257 * sizeof(long)); 257 * sizeof(long));
MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long)); memset(entropy->count_ptrs[tbl], 0, 257 * sizeof(long));
} else { } else {
/* Compute derived values for Huffman table */ /* Compute derived values for Huffman table */
/* We may do this more than once for a table, but it's not expensive */ /* We may do this more than once for a table, but it's not expensive */
@@ -1062,7 +1062,7 @@ finish_pass_gather_phuff(j_compress_ptr cinfo)
/* It's important not to apply jpeg_gen_optimal_table more than once /* It's important not to apply jpeg_gen_optimal_table more than once
* per table, because it clobbers the input frequency counts! * per table, because it clobbers the input frequency counts!
*/ */
MEMZERO(did, sizeof(did)); memset(did, 0, sizeof(did));
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];

View File

@@ -3,8 +3,8 @@
* *
* This file is part of the Independent JPEG Group's software: * This file is part of the Independent JPEG Group's software:
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code relevant * libjpeg-turbo Modifications:
* to libjpeg-turbo. * Copyright (C) 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.
* *
@@ -289,7 +289,7 @@ create_context_buffer(j_compress_ptr cinfo)
cinfo->max_h_samp_factor) / compptr->h_samp_factor), cinfo->max_h_samp_factor) / compptr->h_samp_factor),
(JDIMENSION)(3 * rgroup_height)); (JDIMENSION)(3 * rgroup_height));
/* Copy true buffer row pointers into the middle of the fake row array */ /* Copy true buffer row pointers into the middle of the fake row array */
MEMCOPY(fake_buffer + rgroup_height, true_buffer, memcpy(fake_buffer + rgroup_height, true_buffer,
3 * rgroup_height * sizeof(JSAMPROW)); 3 * rgroup_height * sizeof(JSAMPROW));
/* Fill in the above and below wraparound pointers */ /* Fill in the above and below wraparound pointers */
for (i = 0; i < rgroup_height; i++) { for (i = 0; i < rgroup_height; i++) {

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1995-1998, Thomas G. Lane. * Copyright (C) 1995-1998, Thomas G. Lane.
* Modified 2000-2009 by Guido Vollbeding. * Modified 2000-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2020, D. R. Commander. * Copyright (C) 2020, 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.
* *
@@ -100,7 +100,7 @@ jpeg_copy_critical_parameters(j_decompress_ptr srcinfo, j_compress_ptr dstinfo)
qtblptr = &dstinfo->quant_tbl_ptrs[tblno]; qtblptr = &dstinfo->quant_tbl_ptrs[tblno];
if (*qtblptr == NULL) if (*qtblptr == NULL)
*qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo); *qtblptr = jpeg_alloc_quant_table((j_common_ptr)dstinfo);
MEMCOPY((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval, memcpy((*qtblptr)->quantval, srcinfo->quant_tbl_ptrs[tblno]->quantval,
sizeof((*qtblptr)->quantval)); sizeof((*qtblptr)->quantval));
(*qtblptr)->sent_table = FALSE; (*qtblptr)->sent_table = FALSE;
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1994-1998, Thomas G. Lane. * Copyright (C) 1994-1998, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2016, D. R. Commander. * Copyright (C) 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.
* *
@@ -53,7 +53,7 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
{ {
struct jpeg_error_mgr *err = cinfo->err; struct jpeg_error_mgr *err = cinfo->err;
void *client_data = cinfo->client_data; /* ignore Purify complaint here */ void *client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, sizeof(struct jpeg_decompress_struct)); memset(cinfo, 0, sizeof(struct jpeg_decompress_struct));
cinfo->err = err; cinfo->err = err;
cinfo->client_data = client_data; cinfo->client_data = client_data;
} }
@@ -92,7 +92,7 @@ jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
cinfo->master = (struct jpeg_decomp_master *) cinfo->master = (struct jpeg_decomp_master *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_PERMANENT,
sizeof(my_decomp_master)); sizeof(my_decomp_master));
MEMZERO(cinfo->master, sizeof(my_decomp_master)); memset(cinfo->master, 0, sizeof(my_decomp_master));
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Developed 1997-2015 by Guido Vollbeding. * Developed 1997-2015 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015-2020, D. R. Commander. * Copyright (C) 2015-2020, 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.
* *
@@ -210,13 +210,13 @@ process_restart(j_decompress_ptr cinfo)
for (ci = 0; ci < cinfo->comps_in_scan; ci++) { for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci]; compptr = cinfo->cur_comp_info[ci];
if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) { if (!cinfo->progressive_mode || (cinfo->Ss == 0 && cinfo->Ah == 0)) {
MEMZERO(entropy->dc_stats[compptr->dc_tbl_no], DC_STAT_BINS); memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS);
/* Reset DC predictions to 0 */ /* Reset DC predictions to 0 */
entropy->last_dc_val[ci] = 0; entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0; entropy->dc_context[ci] = 0;
} }
if (!cinfo->progressive_mode || cinfo->Ss) { if (!cinfo->progressive_mode || cinfo->Ss) {
MEMZERO(entropy->ac_stats[compptr->ac_tbl_no], AC_STAT_BINS); memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS);
} }
} }
@@ -715,7 +715,7 @@ bad:
if (entropy->dc_stats[tbl] == NULL) if (entropy->dc_stats[tbl] == NULL)
entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS); ((j_common_ptr)cinfo, JPOOL_IMAGE, DC_STAT_BINS);
MEMZERO(entropy->dc_stats[tbl], DC_STAT_BINS); memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS);
/* Initialize DC predictions to 0 */ /* Initialize DC predictions to 0 */
entropy->last_dc_val[ci] = 0; entropy->last_dc_val[ci] = 0;
entropy->dc_context[ci] = 0; entropy->dc_context[ci] = 0;
@@ -727,7 +727,7 @@ bad:
if (entropy->ac_stats[tbl] == NULL) if (entropy->ac_stats[tbl] == NULL)
entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small)
((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS); ((j_common_ptr)cinfo, JPOOL_IMAGE, AC_STAT_BINS);
MEMZERO(entropy->ac_stats[tbl], AC_STAT_BINS); memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS);
} }
} }

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding. * Modified 2009-2012 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2011, 2014, 2016, 2019, D. R. Commander. * Copyright (C) 2011, 2014, 2016, 2019, 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.
* *
@@ -23,10 +23,6 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.h" #include "jerror.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void *malloc(size_t size);
extern void free(void *ptr);
#endif
void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer, void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
unsigned long *outsize, boolean alloc); unsigned long *outsize, boolean alloc);
@@ -101,7 +97,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
if (nextbuffer == NULL) if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize); memcpy(nextbuffer, dest->buffer, dest->bufsize);
free(dest->newbuffer); free(dest->newbuffer);

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* Modified 2009-2012 by Guido Vollbeding. * Modified 2009-2012 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.
* *
@@ -23,11 +23,6 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.h" #include "jerror.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void *malloc(size_t size);
extern void free(void *ptr);
#endif
/* Expanded data destination object for stdio output */ /* Expanded data destination object for stdio output */
@@ -141,7 +136,7 @@ empty_mem_output_buffer(j_compress_ptr cinfo)
if (nextbuffer == NULL) if (nextbuffer == NULL)
ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10);
MEMCOPY(nextbuffer, dest->buffer, dest->bufsize); memcpy(nextbuffer, dest->buffer, dest->bufsize);
free(dest->newbuffer); free(dest->newbuffer);

View File

@@ -6,7 +6,7 @@
* Modified 2002-2010 by Guido Vollbeding. * Modified 2002-2010 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
* Copyright (C) 2010, 2015, D. R. Commander. * Copyright (C) 2010, 2015, 2022, D. R. Commander.
* Copyright (C) 2013, MIPS Technologies, Inc., California. * Copyright (C) 2013, MIPS Technologies, Inc., California.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
@@ -345,7 +345,7 @@ jinit_inverse_dct(j_decompress_ptr cinfo)
compptr->dct_table = compptr->dct_table =
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(multiplier_table)); sizeof(multiplier_table));
MEMZERO(compptr->dct_table, sizeof(multiplier_table)); memset(compptr->dct_table, 0, sizeof(multiplier_table));
/* Mark multiplier table not yet set up for any method */ /* Mark multiplier table not yet set up for any method */
idct->cur_method[ci] = -1; idct->cur_method[ci] = -1;
} }

View File

@@ -18,10 +18,6 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jerror.h" #include "jerror.h"
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc() */
extern void *malloc(size_t size);
#endif
#define ICC_MARKER (JPEG_APP0 + 2) /* JPEG marker code for ICC */ #define ICC_MARKER (JPEG_APP0 + 2) /* JPEG marker code for ICC */
#define ICC_OVERHEAD_LEN 14 /* size of non-profile data in APP2 */ #define ICC_OVERHEAD_LEN 14 /* size of non-profile data in APP2 */

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2016, 2018, D. R. Commander. * Copyright (C) 2010, 2016, 2018, 2022, D. R. Commander.
* Copyright (C) 2015, Google, Inc. * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
* file. * file.
@@ -264,7 +264,7 @@ latch_quant_tables(j_decompress_ptr cinfo)
qtbl = (JQUANT_TBL *) qtbl = (JQUANT_TBL *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
sizeof(JQUANT_TBL)); sizeof(JQUANT_TBL));
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL)); memcpy(qtbl, cinfo->quant_tbl_ptrs[qtblno], sizeof(JQUANT_TBL));
compptr->quant_table = qtbl; compptr->quant_table = qtbl;
} }
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2012, 2015, D. R. Commander. * Copyright (C) 2012, 2015, 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.
* *
@@ -473,7 +473,7 @@ get_dht(j_decompress_ptr cinfo)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
INPUT_BYTE(cinfo, huffval[i], return FALSE); INPUT_BYTE(cinfo, huffval[i], return FALSE);
MEMZERO(&huffval[count], (256 - count) * sizeof(UINT8)); memset(&huffval[count], 0, (256 - count) * sizeof(UINT8));
length -= count; length -= count;
@@ -491,8 +491,8 @@ get_dht(j_decompress_ptr cinfo)
if (*htblptr == NULL) if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo); *htblptr = jpeg_alloc_huff_table((j_common_ptr)cinfo);
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
MEMCOPY((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval)); memcpy((*htblptr)->huffval, huffval, sizeof((*htblptr)->huffval));
} }
if (length != 0) if (length != 0)

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2002-2009 by Guido Vollbeding. * Modified 2002-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2009-2011, 2016, 2019, D. R. Commander. * Copyright (C) 2009-2011, 2016, 2019, 2022, D. R. Commander.
* Copyright (C) 2013, Linaro Limited. * Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2015, Google, Inc. * Copyright (C) 2015, Google, Inc.
* For conditions of distribution and use, see the accompanying README.ijg * For conditions of distribution and use, see the accompanying README.ijg
@@ -417,7 +417,7 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */ table += (MAXJSAMPLE + 1); /* allow negative subscripts of simple table */
cinfo->sample_range_limit = table; cinfo->sample_range_limit = table;
/* First segment of "simple" table: limit[x] = 0 for x < 0 */ /* First segment of "simple" table: limit[x] = 0 for x < 0 */
MEMZERO(table - (MAXJSAMPLE + 1), (MAXJSAMPLE + 1) * sizeof(JSAMPLE)); memset(table - (MAXJSAMPLE + 1), 0, (MAXJSAMPLE + 1) * sizeof(JSAMPLE));
/* Main part of "simple" table: limit[x] = x */ /* Main part of "simple" table: limit[x] = x */
for (i = 0; i <= MAXJSAMPLE; i++) for (i = 0; i <= MAXJSAMPLE; i++)
table[i] = (JSAMPLE)i; table[i] = (JSAMPLE)i;
@@ -426,9 +426,9 @@ prepare_range_limit_table(j_decompress_ptr cinfo)
for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++) for (i = CENTERJSAMPLE; i < 2 * (MAXJSAMPLE + 1); i++)
table[i] = MAXJSAMPLE; table[i] = MAXJSAMPLE;
/* Second half of post-IDCT table */ /* Second half of post-IDCT table */
MEMZERO(table + (2 * (MAXJSAMPLE + 1)), memset(table + (2 * (MAXJSAMPLE + 1)), 0,
(2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE)); (2 * (MAXJSAMPLE + 1) - CENTERJSAMPLE) * sizeof(JSAMPLE));
MEMCOPY(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE), memcpy(table + (4 * (MAXJSAMPLE + 1) - CENTERJSAMPLE),
cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE)); cinfo->sample_range_limit, CENTERJSAMPLE * sizeof(JSAMPLE));
} }

View File

@@ -24,57 +24,16 @@
#define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
/* /*
* We need the NULL macro and size_t typedef.
* On an ANSI-conforming system it is sufficient to include <stddef.h>.
* Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
* pull in <sys/types.h> as well.
* Note that the core JPEG library does not require <stdio.h>; * Note that the core JPEG library does not require <stdio.h>;
* only the default error handler and data source/destination modules do. * only the default error handler and data source/destination modules do.
* But we must pull it in because of the references to FILE in jpeglib.h. * But we must pull it in because of the references to FILE in jpeglib.h.
* You can remove those references if you want to compile without <stdio.h>. * You can remove those references if you want to compile without <stdio.h>.
*/ */
#ifdef HAVE_STDDEF_H
#include <stddef.h> #include <stddef.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h> #include <stdlib.h>
#endif
#ifdef NEED_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <stdio.h> #include <stdio.h>
/*
* We need memory copying and zeroing functions, plus strncpy().
* ANSI and System V implementations declare these in <string.h>.
* BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
* Some systems may declare memset and memcpy in <memory.h>.
*
* NOTE: we assume the size parameters to these functions are of type size_t.
* Change the casts in these macros if not!
*/
#ifdef NEED_BSD_STRINGS
#include <strings.h>
#define MEMZERO(target, size) \
bzero((void *)(target), (size_t)(size))
#define MEMCOPY(dest, src, size) \
bcopy((const void *)(src), (void *)(dest), (size_t)(size))
#else /* not BSD, assume ANSI/SysV string lib */
#include <string.h> #include <string.h>
#define MEMZERO(target, size) \
memset((void *)(target), 0, (size_t)(size))
#define MEMCOPY(dest, src, size) \
memcpy((void *)(dest), (const void *)(src), (size_t)(size))
#endif
/* /*
* The modules that use fread() and fwrite() always invoke them through * The modules that use fread() and fwrite() always invoke them through

View File

@@ -37,12 +37,6 @@
#endif #endif
#include <limits.h> #include <limits.h>
#ifndef NO_GETENV
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare getenv() */
extern char *getenv(const char *name);
#endif
#endif
LOCAL(size_t) LOCAL(size_t)
round_up_pow2(size_t a, size_t b) round_up_pow2(size_t a, size_t b)

View File

@@ -22,11 +22,6 @@
#include "jpeglib.h" #include "jpeglib.h"
#include "jmemsys.h" /* import the system-dependent declarations */ #include "jmemsys.h" /* import the system-dependent declarations */
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
extern void *malloc(size_t size);
extern void free(void *ptr);
#endif
/* /*
* Memory allocation and freeing are controlled by the regular library * Memory allocation and freeing are controlled by the regular library

View File

@@ -100,11 +100,7 @@ typedef unsigned char UINT8;
/* UINT16 must hold at least the values 0..65535. */ /* UINT16 must hold at least the values 0..65535. */
#ifdef HAVE_UNSIGNED_SHORT
typedef unsigned short UINT16; typedef unsigned short UINT16;
#else /* not HAVE_UNSIGNED_SHORT */
typedef unsigned int UINT16;
#endif /* HAVE_UNSIGNED_SHORT */
/* INT16 must hold at least the values -32768..32767. */ /* INT16 must hold at least the values -32768..32767. */

View File

@@ -373,12 +373,3 @@ extern const int jpeg_natural_order[]; /* zigzag coef order to natural order */
/* Arithmetic coding probability estimation tables in jaricom.c */ /* Arithmetic coding probability estimation tables in jaricom.c */
extern const JLONG jpeg_aritab[]; extern const JLONG jpeg_aritab[];
/* Suppress undefined-structure complaints if necessary. */
#ifdef INCOMPLETE_TYPES_BROKEN
#ifndef AM_MEMORY_MANAGER /* only jmemmgr.c defines these */
struct jvirt_sarray_control { long dummy; };
struct jvirt_barray_control { long dummy; };
#endif
#endif /* INCOMPLETE_TYPES_BROKEN */

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1998, Thomas G. Lane. * Copyright (C) 1991-1998, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2013, D. R. Commander. * Copyright (C) 2013, 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.
* *
@@ -29,7 +29,7 @@ add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
return; return;
/* Copy the number-of-symbols-of-each-code-length counts */ /* Copy the number-of-symbols-of-each-code-length counts */
MEMCOPY((*htblptr)->bits, bits, sizeof((*htblptr)->bits)); memcpy((*htblptr)->bits, bits, sizeof((*htblptr)->bits));
/* Validate the counts. We do this here mainly so we can copy the right /* Validate the counts. We do this here mainly so we can copy the right
* number of symbols from the val[] array, without risking marching off * number of symbols from the val[] array, without risking marching off
@@ -41,8 +41,9 @@ add_huff_table(j_common_ptr cinfo, JHUFF_TBL **htblptr, const UINT8 *bits,
if (nsymbols < 1 || nsymbols > 256) if (nsymbols < 1 || nsymbols > 256)
ERREXIT(cinfo, JERR_BAD_HUFF_TABLE); ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
MEMCOPY((*htblptr)->huffval, val, nsymbols * sizeof(UINT8)); memcpy((*htblptr)->huffval, val, nsymbols * sizeof(UINT8));
MEMZERO(&((*htblptr)->huffval[nsymbols]), (256 - nsymbols) * sizeof(UINT8)); memset(&((*htblptr)->huffval[nsymbols]), 0,
(256 - nsymbols) * sizeof(UINT8));
/* Initialize sent_table FALSE so table will be written to JPEG file. */ /* Initialize sent_table FALSE so table will be written to JPEG file. */
(*htblptr)->sent_table = FALSE; (*htblptr)->sent_table = FALSE;

View File

@@ -3,8 +3,8 @@
* *
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* It was modified by The libjpeg-turbo Project to include only code * libjpeg-turbo Modifications:
* relevant to libjpeg-turbo. * Copyright (C) 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.
* *
@@ -110,7 +110,7 @@ jcopy_sample_rows(JSAMPARRAY input_array, int source_row,
for (row = num_rows; row > 0; row--) { for (row = num_rows; row > 0; row--) {
inptr = *input_array++; inptr = *input_array++;
outptr = *output_array++; outptr = *output_array++;
MEMCOPY(outptr, inptr, count); memcpy(outptr, inptr, count);
} }
} }
@@ -120,7 +120,7 @@ jcopy_block_row(JBLOCKROW input_row, JBLOCKROW output_row,
JDIMENSION num_blocks) JDIMENSION num_blocks)
/* Copy a row of coefficient blocks from one place to another. */ /* Copy a row of coefficient blocks from one place to another. */
{ {
MEMCOPY(output_row, input_row, num_blocks * (DCTSIZE2 * sizeof(JCOEF))); memcpy(output_row, input_row, num_blocks * (DCTSIZE2 * sizeof(JCOEF)));
} }
@@ -129,5 +129,5 @@ jzero_far(void *target, size_t bytestozero)
/* Zero out a chunk of memory. */ /* Zero out a chunk of memory. */
/* This might be sample-array data, block-array data, or alloc_large data. */ /* This might be sample-array data, block-array data, or alloc_large data. */
{ {
MEMZERO(target, bytestozero); memset(target, 0, bytestozero);
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding. * Copyright (C) 1991-2020, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2012-2021, D. R. Commander. * Copyright (C) 2010, 2012-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.
* *
@@ -37,7 +37,7 @@
*/ */
#define JCOPYRIGHT \ #define JCOPYRIGHT \
"Copyright (C) 2009-2021 D. R. Commander\n" \ "Copyright (C) 2009-2022 D. R. Commander\n" \
"Copyright (C) 2015, 2020 Google, Inc.\n" \ "Copyright (C) 2015, 2020 Google, Inc.\n" \
"Copyright (C) 2019-2020 Arm Limited\n" \ "Copyright (C) 2019-2020 Arm Limited\n" \
"Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \ "Copyright (C) 2015-2016, 2018 Matthieu Darbois\n" \
@@ -51,4 +51,4 @@
"Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding" "Copyright (C) 1991-2020 Thomas G. Lane, Guido Vollbeding"
#define JCOPYRIGHT_SHORT \ #define JCOPYRIGHT_SHORT \
"Copyright (C) 1991-2021 The libjpeg-turbo Project and many others" "Copyright (C) 1991-2022 The libjpeg-turbo Project and many others"

View File

@@ -6,7 +6,7 @@
* Modified 2009-2017 by Guido Vollbeding. * Modified 2009-2017 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Modified 2011 by Siarhei Siamashka. * Modified 2011 by Siarhei Siamashka.
* Copyright (C) 2015, 2017-2018, 2021, D. R. Commander. * Copyright (C) 2015, 2017-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.
* *
@@ -246,7 +246,7 @@ get_24bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
*/ */
outptr = source->pub.buffer[0]; outptr = source->pub.buffer[0];
if (cinfo->in_color_space == JCS_EXT_BGR) { if (cinfo->in_color_space == JCS_EXT_BGR) {
MEMCOPY(outptr, inptr, source->row_width); memcpy(outptr, inptr, source->row_width);
} else if (cinfo->in_color_space == JCS_CMYK) { } else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) { for (col = cinfo->image_width; col > 0; col--) {
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++; JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;
@@ -310,7 +310,7 @@ get_32bit_row(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
outptr = source->pub.buffer[0]; outptr = source->pub.buffer[0];
if (cinfo->in_color_space == JCS_EXT_BGRX || if (cinfo->in_color_space == JCS_EXT_BGRX ||
cinfo->in_color_space == JCS_EXT_BGRA) { cinfo->in_color_space == JCS_EXT_BGRA) {
MEMCOPY(outptr, inptr, source->row_width); memcpy(outptr, inptr, source->row_width);
} else if (cinfo->in_color_space == JCS_CMYK) { } else if (cinfo->in_color_space == JCS_CMYK) {
for (col = cinfo->image_width; col > 0; col--) { for (col = cinfo->image_width; col > 0; col--) {
JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++; JSAMPLE b = *inptr++, g = *inptr++, r = *inptr++;

View File

@@ -18,9 +18,7 @@
#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ #define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */
#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ #include "jinclude.h" /* get auto-config symbols, <stdio.h> */
#ifdef HAVE_LOCALE_H
#include <locale.h> /* Bill Allombert: use locale for isprint */ #include <locale.h> /* Bill Allombert: use locale for isprint */
#endif
#include <ctype.h> /* to declare isupper(), tolower() */ #include <ctype.h> /* to declare isupper(), tolower() */
#ifdef USE_SETMODE #ifdef USE_SETMODE
#include <fcntl.h> /* to declare setmode()'s parameter macros */ #include <fcntl.h> /* to declare setmode()'s parameter macros */
@@ -223,9 +221,7 @@ process_COM(int raw)
int lastch = 0; int lastch = 0;
/* Bill Allombert: set locale properly for isprint */ /* Bill Allombert: set locale properly for isprint */
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, ""); setlocale(LC_CTYPE, "");
#endif
/* Get the marker parameter length count */ /* Get the marker parameter length count */
length = read_2_bytes(); length = read_2_bytes();
@@ -261,9 +257,7 @@ process_COM(int raw)
printf("\n"); printf("\n");
/* Bill Allombert: revert to C locale */ /* Bill Allombert: revert to C locale */
#ifdef HAVE_LOCALE_H
setlocale(LC_CTYPE, "C"); setlocale(LC_CTYPE, "C");
#endif
} }

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2009 by Bill Allombert, Guido Vollbeding. * Modified 2009 by Bill Allombert, Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015-2017, 2020-2021, D. R. Commander. * Copyright (C) 2015-2017, 2020-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.
* *
@@ -732,7 +732,7 @@ start_input_ppm(j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
(size_t)(((long)MAX(maxval, 255) + 1L) * (size_t)(((long)MAX(maxval, 255) + 1L) *
sizeof(JSAMPLE))); sizeof(JSAMPLE)));
MEMZERO(source->rescale, (size_t)(((long)MAX(maxval, 255) + 1L) * memset(source->rescale, 0, (size_t)(((long)MAX(maxval, 255) + 1L) *
sizeof(JSAMPLE))); sizeof(JSAMPLE)));
half_maxval = maxval / 2; half_maxval = maxval / 2;
for (val = 0; val <= (long)maxval; val++) { for (val = 0; val <= (long)maxval; val++) {

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2018, D. R. Commander. * Copyright (C) 2010, 2018, 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.
* *
@@ -263,7 +263,7 @@ bogus:
scanptr = (jpeg_scan_info *) scanptr = (jpeg_scan_info *)
(*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
scanno * sizeof(jpeg_scan_info)); scanno * sizeof(jpeg_scan_info));
MEMCOPY(scanptr, scans, scanno * sizeof(jpeg_scan_info)); memcpy(scanptr, scans, scanno * sizeof(jpeg_scan_info));
cinfo->scan_info = scanptr; cinfo->scan_info = scanptr;
cinfo->num_scans = scanno; cinfo->num_scans = scanno;
} }

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding. * Copyright (C) 1997-2019, Thomas G. Lane, Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2010, 2017, 2021, D. R. Commander. * Copyright (C) 2010, 2017, 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.
* *
@@ -262,7 +262,7 @@ do_drop(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
} }
} else { } else {
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(dst_buffer[offset_y] + x_drop_blocks, memset(dst_buffer[offset_y] + x_drop_blocks, 0,
comp_width * sizeof(JBLOCK)); comp_width * sizeof(JBLOCK));
} }
} }
@@ -345,7 +345,7 @@ do_crop_ext_zero(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
if (dst_blk_y < y_crop_blocks || if (dst_blk_y < y_crop_blocks ||
dst_blk_y >= y_crop_blocks + comp_height) { dst_blk_y >= y_crop_blocks + comp_height) {
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(dst_buffer[offset_y], memset(dst_buffer[offset_y], 0,
compptr->width_in_blocks * sizeof(JBLOCK)); compptr->width_in_blocks * sizeof(JBLOCK));
} }
continue; continue;
@@ -363,12 +363,12 @@ do_crop_ext_zero(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
if (dstinfo->_jpeg_width > srcinfo->output_width) { if (dstinfo->_jpeg_width > srcinfo->output_width) {
if (x_crop_blocks > 0) { if (x_crop_blocks > 0) {
MEMZERO(dst_buffer[offset_y], x_crop_blocks * sizeof(JBLOCK)); memset(dst_buffer[offset_y], 0, x_crop_blocks * sizeof(JBLOCK));
} }
jcopy_block_row(src_buffer[offset_y], jcopy_block_row(src_buffer[offset_y],
dst_buffer[offset_y] + x_crop_blocks, comp_width); dst_buffer[offset_y] + x_crop_blocks, comp_width);
if (compptr->width_in_blocks > x_crop_blocks + comp_width) { if (compptr->width_in_blocks > x_crop_blocks + comp_width) {
MEMZERO(dst_buffer[offset_y] + x_crop_blocks + comp_width, memset(dst_buffer[offset_y] + x_crop_blocks + comp_width, 0,
(compptr->width_in_blocks - x_crop_blocks - comp_width) * (compptr->width_in_blocks - x_crop_blocks - comp_width) *
sizeof(JBLOCK)); sizeof(JBLOCK));
} }
@@ -421,7 +421,7 @@ do_crop_ext_flat(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
if (dst_blk_y < y_crop_blocks || if (dst_blk_y < y_crop_blocks ||
dst_blk_y >= y_crop_blocks + comp_height) { dst_blk_y >= y_crop_blocks + comp_height) {
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(dst_buffer[offset_y], memset(dst_buffer[offset_y], 0,
compptr->width_in_blocks * sizeof(JBLOCK)); compptr->width_in_blocks * sizeof(JBLOCK));
} }
continue; continue;
@@ -438,7 +438,7 @@ do_crop_ext_flat(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
} }
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
if (x_crop_blocks > 0) { if (x_crop_blocks > 0) {
MEMZERO(dst_buffer[offset_y], x_crop_blocks * sizeof(JBLOCK)); memset(dst_buffer[offset_y], 0, x_crop_blocks * sizeof(JBLOCK));
dc = src_buffer[offset_y][0][0]; dc = src_buffer[offset_y][0][0];
for (dst_blk_x = 0; dst_blk_x < x_crop_blocks; dst_blk_x++) { for (dst_blk_x = 0; dst_blk_x < x_crop_blocks; dst_blk_x++) {
dst_buffer[offset_y][dst_blk_x][0] = dc; dst_buffer[offset_y][dst_blk_x][0] = dc;
@@ -447,7 +447,7 @@ do_crop_ext_flat(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
jcopy_block_row(src_buffer[offset_y], jcopy_block_row(src_buffer[offset_y],
dst_buffer[offset_y] + x_crop_blocks, comp_width); dst_buffer[offset_y] + x_crop_blocks, comp_width);
if (compptr->width_in_blocks > x_crop_blocks + comp_width) { if (compptr->width_in_blocks > x_crop_blocks + comp_width) {
MEMZERO(dst_buffer[offset_y] + x_crop_blocks + comp_width, memset(dst_buffer[offset_y] + x_crop_blocks + comp_width, 0,
(compptr->width_in_blocks - x_crop_blocks - comp_width) * (compptr->width_in_blocks - x_crop_blocks - comp_width) *
sizeof(JBLOCK)); sizeof(JBLOCK));
dc = src_buffer[offset_y][comp_width - 1][0]; dc = src_buffer[offset_y][comp_width - 1][0];
@@ -502,7 +502,7 @@ do_crop_ext_reflect(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
if (dst_blk_y < y_crop_blocks || if (dst_blk_y < y_crop_blocks ||
dst_blk_y >= y_crop_blocks + comp_height) { dst_blk_y >= y_crop_blocks + comp_height) {
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(dst_buffer[offset_y], memset(dst_buffer[offset_y], 0,
compptr->width_in_blocks * sizeof(JBLOCK)); compptr->width_in_blocks * sizeof(JBLOCK));
} }
continue; continue;
@@ -591,7 +591,8 @@ do_wipe(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks, ((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks,
(JDIMENSION)compptr->v_samp_factor, TRUE); (JDIMENSION)compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(buffer[offset_y] + x_wipe_blocks, wipe_width * sizeof(JBLOCK)); memset(buffer[offset_y] + x_wipe_blocks, 0,
wipe_width * sizeof(JBLOCK));
} }
} }
} }
@@ -626,7 +627,8 @@ do_flatten(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks, ((j_common_ptr)srcinfo, src_coef_arrays[ci], y_wipe_blocks,
(JDIMENSION)compptr->v_samp_factor, TRUE); (JDIMENSION)compptr->v_samp_factor, TRUE);
for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) { for (offset_y = 0; offset_y < compptr->v_samp_factor; offset_y++) {
MEMZERO(buffer[offset_y] + x_wipe_blocks, wipe_width * sizeof(JBLOCK)); memset(buffer[offset_y] + x_wipe_blocks, 0,
wipe_width * sizeof(JBLOCK));
if (x_wipe_blocks > 0) { if (x_wipe_blocks > 0) {
dc_left_value = buffer[offset_y][x_wipe_blocks - 1][0]; dc_left_value = buffer[offset_y][x_wipe_blocks - 1][0];
if (wipe_right < compptr->width_in_blocks) { if (wipe_right < compptr->width_in_blocks) {
@@ -709,7 +711,7 @@ do_reflect(j_decompress_ptr srcinfo, j_compress_ptr dstinfo,
} }
} }
} else { } else {
MEMZERO(buffer[offset_y] + x_wipe_blocks, memset(buffer[offset_y] + x_wipe_blocks, 0,
wipe_width * sizeof(JBLOCK)); wipe_width * sizeof(JBLOCK));
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C)2009-2021 D. R. Commander. All Rights Reserved. * Copyright (C)2009-2022 D. R. Commander. All Rights Reserved.
* Copyright (C)2021 Alex Richardson. All Rights Reserved. * Copyright (C)2021 Alex Richardson. All Rights Reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -514,7 +514,7 @@ DLLEXPORT tjhandle tjInitCompress(void)
"tjInitCompress(): Memory allocation failure"); "tjInitCompress(): Memory allocation failure");
return NULL; return NULL;
} }
MEMZERO(this, sizeof(tjinstance)); memset(this, 0, sizeof(tjinstance));
snprintf(this->errStr, JMSG_LENGTH_MAX, "No error"); snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
return _tjInitCompress(this); return _tjInitCompress(this);
} }
@@ -1186,7 +1186,7 @@ DLLEXPORT tjhandle tjInitDecompress(void)
"tjInitDecompress(): Memory allocation failure"); "tjInitDecompress(): Memory allocation failure");
return NULL; return NULL;
} }
MEMZERO(this, sizeof(tjinstance)); memset(this, 0, sizeof(tjinstance));
snprintf(this->errStr, JMSG_LENGTH_MAX, "No error"); snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
return _tjInitDecompress(this); return _tjInitDecompress(this);
} }
@@ -1301,7 +1301,7 @@ DLLEXPORT int tjDecompress2(tjhandle handle, const unsigned char *jpegBuf,
#endif #endif
if (flags & TJFLAG_LIMITSCANS) { if (flags & TJFLAG_LIMITSCANS) {
MEMZERO(&progress, sizeof(struct my_progress_mgr)); memset(&progress, 0, sizeof(struct my_progress_mgr));
progress.pub.progress_monitor = my_progress_monitor; progress.pub.progress_monitor = my_progress_monitor;
progress.this = this; progress.this = this;
dinfo->progress = &progress.pub; dinfo->progress = &progress.pub;
@@ -1649,7 +1649,7 @@ DLLEXPORT int tjDecompressToYUVPlanes(tjhandle handle,
#endif #endif
if (flags & TJFLAG_LIMITSCANS) { if (flags & TJFLAG_LIMITSCANS) {
MEMZERO(&progress, sizeof(struct my_progress_mgr)); memset(&progress, 0, sizeof(struct my_progress_mgr));
progress.pub.progress_monitor = my_progress_monitor; progress.pub.progress_monitor = my_progress_monitor;
progress.this = this; progress.this = this;
dinfo->progress = &progress.pub; dinfo->progress = &progress.pub;
@@ -1877,7 +1877,7 @@ DLLEXPORT tjhandle tjInitTransform(void)
"tjInitTransform(): Memory allocation failure"); "tjInitTransform(): Memory allocation failure");
return NULL; return NULL;
} }
MEMZERO(this, sizeof(tjinstance)); memset(this, 0, sizeof(tjinstance));
snprintf(this->errStr, JMSG_LENGTH_MAX, "No error"); snprintf(this->errStr, JMSG_LENGTH_MAX, "No error");
handle = _tjInitCompress(this); handle = _tjInitCompress(this);
if (!handle) return NULL; if (!handle) return NULL;
@@ -1912,7 +1912,7 @@ DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
#endif #endif
if (flags & TJFLAG_LIMITSCANS) { if (flags & TJFLAG_LIMITSCANS) {
MEMZERO(&progress, sizeof(struct my_progress_mgr)); memset(&progress, 0, sizeof(struct my_progress_mgr));
progress.pub.progress_monitor = my_progress_monitor; progress.pub.progress_monitor = my_progress_monitor;
progress.this = this; progress.this = this;
dinfo->progress = &progress.pub; dinfo->progress = &progress.pub;
@@ -1922,7 +1922,7 @@ DLLEXPORT int tjTransform(tjhandle handle, const unsigned char *jpegBuf,
if ((xinfo = if ((xinfo =
(jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL) (jpeg_transform_info *)malloc(sizeof(jpeg_transform_info) * n)) == NULL)
THROW("tjTransform(): Memory allocation failure"); THROW("tjTransform(): Memory allocation failure");
MEMZERO(xinfo, sizeof(jpeg_transform_info) * n); memset(xinfo, 0, sizeof(jpeg_transform_info) * n);
if (setjmp(this->jerr.setjmp_buffer)) { if (setjmp(this->jerr.setjmp_buffer)) {
/* If we get here, the JPEG code has signaled an error. */ /* If we get here, the JPEG code has signaled an error. */

View File

@@ -9,14 +9,6 @@
#define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */ #define BITS_IN_JSAMPLE @BITS_IN_JSAMPLE@ /* use 8 or 12 */
#define HAVE_STDDEF_H
#define HAVE_STDLIB_H
#undef NEED_SYS_TYPES_H
#undef NEED_BSD_STRINGS
#define HAVE_UNSIGNED_CHAR
#define HAVE_UNSIGNED_SHORT
#undef INCOMPLETE_TYPES_BROKEN
#undef RIGHT_SHIFT_IS_UNSIGNED #undef RIGHT_SHIFT_IS_UNSIGNED
/* Define "boolean" as unsigned char, not int, per Windows custom */ /* Define "boolean" as unsigned char, not int, per Windows custom */

14
wrbmp.c
View File

@@ -5,7 +5,7 @@
* Copyright (C) 1994-1996, Thomas G. Lane. * Copyright (C) 1994-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2013, Linaro Limited. * Copyright (C) 2013, Linaro Limited.
* Copyright (C) 2014-2015, 2017, 2019, D. R. Commander. * Copyright (C) 2014-2015, 2017, 2019, 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.
* *
@@ -121,7 +121,7 @@ put_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
inptr = dest->pub.buffer[0]; inptr = dest->pub.buffer[0];
if (cinfo->out_color_space == JCS_EXT_BGR) { if (cinfo->out_color_space == JCS_EXT_BGR) {
MEMCOPY(outptr, inptr, dest->row_width); memcpy(outptr, inptr, dest->row_width);
outptr += cinfo->output_width * 3; outptr += cinfo->output_width * 3;
} else if (cinfo->out_color_space == JCS_RGB565) { } else if (cinfo->out_color_space == JCS_RGB565) {
boolean big_endian = is_big_endian(); boolean big_endian = is_big_endian();
@@ -191,7 +191,7 @@ put_gray_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
/* Transfer data. */ /* Transfer data. */
inptr = dest->pub.buffer[0]; inptr = dest->pub.buffer[0];
MEMCOPY(outptr, inptr, cinfo->output_width); memcpy(outptr, inptr, cinfo->output_width);
outptr += cinfo->output_width; outptr += cinfo->output_width;
/* Zero out the pad bytes. */ /* Zero out the pad bytes. */
@@ -256,8 +256,8 @@ write_bmp_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height; bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height;
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(bmpfileheader, sizeof(bmpfileheader)); memset(bmpfileheader, 0, sizeof(bmpfileheader));
MEMZERO(bmpinfoheader, sizeof(bmpinfoheader)); memset(bmpinfoheader, 0, sizeof(bmpinfoheader));
/* Fill the file header */ /* Fill the file header */
bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */
@@ -325,8 +325,8 @@ write_os2_header(j_decompress_ptr cinfo, bmp_dest_ptr dest)
bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height; bfSize = headersize + (long)dest->row_width * (long)cinfo->output_height;
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(bmpfileheader, sizeof(bmpfileheader)); memset(bmpfileheader, 0, sizeof(bmpfileheader));
MEMZERO(bmpcoreheader, sizeof(bmpcoreheader)); memset(bmpcoreheader, 0, sizeof(bmpcoreheader));
/* Fill the file header */ /* Fill the file header */
bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */ bmpfileheader[0] = 0x42; /* first 2 bytes are ASCII 'B', 'M' */

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1991-1997, Thomas G. Lane. * Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 2015-2019 by Guido Vollbeding. * Modified 2015-2019 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2015, 2017, D. R. Commander. * Copyright (C) 2015, 2017, 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.
* *
@@ -169,7 +169,7 @@ clear_hash(gif_dest_ptr dinfo)
/* Fill the hash table with empty entries */ /* Fill the hash table with empty entries */
{ {
/* It's sufficient to zero hash_code[] */ /* It's sufficient to zero hash_code[] */
MEMZERO(dinfo->hash_code, HSIZE * sizeof(code_int)); memset(dinfo->hash_code, 0, HSIZE * sizeof(code_int));
} }

View File

@@ -17,9 +17,6 @@
#define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */ #define JPEG_CJPEG_DJPEG /* to get the command-line config symbols */
#include "jinclude.h" /* get auto-config symbols, <stdio.h> */ #include "jinclude.h" /* get auto-config symbols, <stdio.h> */
#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc() */
extern void *malloc();
#endif
#include <ctype.h> /* to declare isupper(), tolower() */ #include <ctype.h> /* to declare isupper(), tolower() */
#ifdef USE_SETMODE #ifdef USE_SETMODE
#include <fcntl.h> /* to declare setmode()'s parameter macros */ #include <fcntl.h> /* to declare setmode()'s parameter macros */

View File

@@ -5,7 +5,7 @@
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* Modified 2009 by Guido Vollbeding. * Modified 2009 by Guido Vollbeding.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2017, 2019-2020, D. R. Commander. * Copyright (C) 2017, 2019-2020, 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.
* *
@@ -115,7 +115,7 @@ copy_pixel_rows(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
ptr = dest->pub.buffer[0]; ptr = dest->pub.buffer[0];
bufferptr = dest->iobuffer; bufferptr = dest->iobuffer;
#if BITS_IN_JSAMPLE == 8 #if BITS_IN_JSAMPLE == 8
MEMCOPY(bufferptr, ptr, dest->samples_per_row); memcpy(bufferptr, ptr, dest->samples_per_row);
#else #else
for (col = dest->samples_per_row; col > 0; col--) { for (col = dest->samples_per_row; col > 0; col--) {
PUTPPMSAMPLE(bufferptr, *ptr++); PUTPPMSAMPLE(bufferptr, *ptr++);

View File

@@ -4,7 +4,7 @@
* This file was part of the Independent JPEG Group's software: * This file was part of the Independent JPEG Group's software:
* Copyright (C) 1991-1996, Thomas G. Lane. * Copyright (C) 1991-1996, Thomas G. Lane.
* libjpeg-turbo Modifications: * libjpeg-turbo Modifications:
* Copyright (C) 2017, 2019, D. R. Commander. * Copyright (C) 2017, 2019, 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.
* *
@@ -51,7 +51,7 @@ write_header(j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
char targaheader[18]; char targaheader[18];
/* Set unused fields of header to 0 */ /* Set unused fields of header to 0 */
MEMZERO(targaheader, sizeof(targaheader)); memset(targaheader, 0, sizeof(targaheader));
if (num_colors > 0) { if (num_colors > 0) {
targaheader[1] = 1; /* color map type 1 */ targaheader[1] = 1; /* color map type 1 */
@@ -121,7 +121,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;
MEMCOPY(outptr, inptr, cinfo->output_width); memcpy(outptr, inptr, cinfo->output_width);
(void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width); (void)JFWRITE(dest->pub.output_file, dest->iobuffer, dest->buffer_width);
} }