Skip to content

Commit

Permalink
Use consistent/modern code formatting for pointers
Browse files Browse the repository at this point in the history
The convention used by libjpeg:

    type * variable;

is not very common anymore, because it looks too much like
multiplication.  Some (particularly C++ programmers) prefer to tuck the
pointer symbol against the type:

    type* variable;

to emphasize that a pointer to a type is effectively a new type.
However, this can also be confusing, since defining multiple variables
on the same line would not work properly:

    type* variable1, variable2;  /* Only variable1 is actually a
                                    pointer. */

This commit reformats the entirety of the libjpeg-turbo code base so
that it uses the same code formatting convention for pointers that the
TurboJPEG API code uses:

    type *variable1, *variable2;

This seems to be the most common convention among C programmers, and
it is the convention used by other codec libraries, such as libpng and
libtiff.
  • Loading branch information
dcommander committed Feb 19, 2016
1 parent ae41128 commit bd49803
Show file tree
Hide file tree
Showing 125 changed files with 980 additions and 978 deletions.
2 changes: 1 addition & 1 deletion cdjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ end_progress_monitor (j_common_ptr cinfo)
*/

GLOBAL(boolean)
keymatch (char * arg, const char * keyword, int minchars)
keymatch (char *arg, const char *keyword, int minchars)
{
register int ca, ck;
register int nmatched = 0;
Expand Down
16 changes: 8 additions & 8 deletions cdjpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* Object interface for cjpeg's source file decoding modules
*/

typedef struct cjpeg_source_struct * cjpeg_source_ptr;
typedef struct cjpeg_source_struct *cjpeg_source_ptr;

struct cjpeg_source_struct {
void (*start_input) (j_compress_ptr cinfo, cjpeg_source_ptr sinfo);
Expand All @@ -42,7 +42,7 @@ struct cjpeg_source_struct {
* Object interface for djpeg's output file encoding modules
*/

typedef struct djpeg_dest_struct * djpeg_dest_ptr;
typedef struct djpeg_dest_struct *djpeg_dest_ptr;

struct djpeg_dest_struct {
/* start_output is called after jpeg_start_decompress finishes.
Expand All @@ -56,7 +56,7 @@ struct djpeg_dest_struct {
void (*finish_output) (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo);

/* Target file spec; filled in by djpeg.c after object is created. */
FILE * output_file;
FILE *output_file;

/* Output pixel-row buffer. Created by module init or start_output.
* Width is cinfo->output_width * cinfo->output_components;
Expand All @@ -83,7 +83,7 @@ struct cdjpeg_progress_mgr {
int percent_done;
};

typedef struct cdjpeg_progress_mgr * cd_progress_ptr;
typedef struct cdjpeg_progress_mgr *cd_progress_ptr;


/* Module selection routines for I/O modules. */
Expand All @@ -102,25 +102,25 @@ EXTERN(djpeg_dest_ptr) jinit_write_targa (j_decompress_ptr cinfo);

/* cjpeg support routines (in rdswitch.c) */

EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char * filename,
EXTERN(boolean) read_quant_tables (j_compress_ptr cinfo, char *filename,
boolean force_baseline);
EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char * filename);
EXTERN(boolean) read_scan_script (j_compress_ptr cinfo, char *filename);
EXTERN(boolean) set_quality_ratings (j_compress_ptr cinfo, char *arg,
boolean force_baseline);
EXTERN(boolean) set_quant_slots (j_compress_ptr cinfo, char *arg);
EXTERN(boolean) set_sample_factors (j_compress_ptr cinfo, char *arg);

/* djpeg support routines (in rdcolmap.c) */

EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE * infile);
EXTERN(void) read_color_map (j_decompress_ptr cinfo, FILE *infile);

/* common support routines (in cdjpeg.c) */

EXTERN(void) enable_signal_catcher (j_common_ptr cinfo);
EXTERN(void) start_progress_monitor (j_common_ptr cinfo,
cd_progress_ptr progress);
EXTERN(void) end_progress_monitor (j_common_ptr cinfo);
EXTERN(boolean) keymatch (char * arg, const char * keyword, int minchars);
EXTERN(boolean) keymatch (char *arg, const char *keyword, int minchars);
EXTERN(FILE *) read_stdin (void);
EXTERN(FILE *) write_stdout (void);

Expand Down
22 changes: 11 additions & 11 deletions cjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static boolean is_targa; /* records user -targa switch */


LOCAL(cjpeg_source_ptr)
select_file_type (j_compress_ptr cinfo, FILE * infile)
select_file_type (j_compress_ptr cinfo, FILE *infile)
{
int c;

Expand Down Expand Up @@ -138,8 +138,8 @@ select_file_type (j_compress_ptr cinfo, FILE * infile)
*/


static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
static const char *progname; /* program name for error messages */
static char *outfilename; /* for -outfile switch */
boolean memdst; /* for -memdst switch */


Expand Down Expand Up @@ -220,14 +220,14 @@ parse_switches (j_compress_ptr cinfo, int argc, char **argv,
*/
{
int argn;
char * arg;
char *arg;
boolean force_baseline;
boolean simple_progressive;
char * qualityarg = NULL; /* saves -quality parm if any */
char * qtablefile = NULL; /* saves -qtables filename if any */
char * qslotsarg = NULL; /* saves -qslots parm if any */
char * samplearg = NULL; /* saves -sample parm if any */
char * scansarg = NULL; /* saves -scans parm if any */
char *qualityarg = NULL; /* saves -quality parm if any */
char *qtablefile = NULL; /* saves -qtables filename if any */
char *qslotsarg = NULL; /* saves -qslots parm if any */
char *samplearg = NULL; /* saves -sample parm if any */
char *scansarg = NULL; /* saves -scans parm if any */

/* Set up default JPEG parameters. */

Expand Down Expand Up @@ -495,8 +495,8 @@ main (int argc, char **argv)
#endif
int file_index;
cjpeg_source_ptr src_mgr;
FILE * input_file;
FILE * output_file = NULL;
FILE *input_file;
FILE *output_file = NULL;
unsigned char *outbuffer = NULL;
unsigned long outsize = 0;
JDIMENSION num_scanlines;
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ prefix=${old_prefix}

# Check whether compiler supports pointers to undefined structures
AC_MSG_CHECKING(whether compiler supports pointers to undefined structures)
AC_TRY_COMPILE([ typedef struct undefined_structure * undef_struct_ptr; ], ,
AC_TRY_COMPILE([ typedef struct undefined_structure *undef_struct_ptr; ], ,
AC_MSG_RESULT(yes),
[AC_MSG_RESULT(no)
AC_DEFINE([INCOMPLETE_TYPES_BROKEN], [1],
Expand Down
14 changes: 7 additions & 7 deletions djpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ static IMAGE_FORMATS requested_fmt;
*/


static const char * progname; /* program name for error messages */
static char * outfilename; /* for -outfile switch */
static const char *progname; /* program name for error messages */
static char *outfilename; /* for -outfile switch */
boolean memsrc; /* for -memsrc switch */
boolean strip, skip;
JDIMENSION startY, endY;
Expand Down Expand Up @@ -190,7 +190,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
*/
{
int argn;
char * arg;
char *arg;

/* Set up default JPEG parameters. */
requested_fmt = DEFAULT_FMT; /* set default output file format */
Expand Down Expand Up @@ -307,7 +307,7 @@ parse_switches (j_decompress_ptr cinfo, int argc, char **argv,
usage();
if (for_real) { /* too expensive to do twice! */
#ifdef QUANT_2PASS_SUPPORTED /* otherwise can't quantize to supplied map */
FILE * mapfile;
FILE *mapfile;

if ((mapfile = fopen(argv[argn], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
Expand Down Expand Up @@ -417,7 +417,7 @@ LOCAL(unsigned int)
jpeg_getc (j_decompress_ptr cinfo)
/* Read next byte */
{
struct jpeg_source_mgr * datasrc = cinfo->src;
struct jpeg_source_mgr *datasrc = cinfo->src;

if (datasrc->bytes_in_buffer == 0) {
if (! (*datasrc->fill_input_buffer) (cinfo))
Expand Down Expand Up @@ -493,8 +493,8 @@ main (int argc, char **argv)
#endif
int file_index;
djpeg_dest_ptr dest_mgr = NULL;
FILE * input_file;
FILE * output_file;
FILE *input_file;
FILE *output_file;
unsigned char *inbuffer = NULL;
unsigned long insize = 0;
JDIMENSION num_scanlines;
Expand Down
12 changes: 6 additions & 6 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
* RGB color and is described by:
*/

extern JSAMPLE * image_buffer; /* Points to large array of R,G,B-order data */
extern JSAMPLE *image_buffer; /* Points to large array of R,G,B-order data */
extern int image_height; /* Number of rows in image */
extern int image_width; /* Number of columns in image */

Expand All @@ -69,7 +69,7 @@ extern int image_width; /* Number of columns in image */
*/

GLOBAL(void)
write_JPEG_file (char * filename, int quality)
write_JPEG_file (char *filename, int quality)
{
/* This struct contains the JPEG compression parameters and pointers to
* working space (which is allocated as needed by the JPEG library).
Expand All @@ -88,7 +88,7 @@ write_JPEG_file (char * filename, int quality)
*/
struct jpeg_error_mgr jerr;
/* More stuff */
FILE * outfile; /* target file */
FILE *outfile; /* target file */
JSAMPROW row_pointer[1]; /* pointer to JSAMPLE row[s] */
int row_stride; /* physical row width in image buffer */

Expand Down Expand Up @@ -253,7 +253,7 @@ struct my_error_mgr {
jmp_buf setjmp_buffer; /* for return to caller */
};

typedef struct my_error_mgr * my_error_ptr;
typedef struct my_error_mgr *my_error_ptr;

/*
* Here's the routine that will replace the standard error_exit method:
Expand Down Expand Up @@ -281,7 +281,7 @@ my_error_exit (j_common_ptr cinfo)


GLOBAL(int)
read_JPEG_file (char * filename)
read_JPEG_file (char *filename)
{
/* This struct contains the JPEG decompression parameters and pointers to
* working space (which is allocated as needed by the JPEG library).
Expand All @@ -293,7 +293,7 @@ read_JPEG_file (char * filename)
*/
struct my_error_mgr jerr;
/* More stuff */
FILE * infile; /* source file */
FILE *infile; /* source file */
JSAMPARRAY buffer; /* Output row buffer */
int row_stride; /* physical row width in output buffer */

Expand Down
8 changes: 4 additions & 4 deletions jcapimin.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ jpeg_CreateCompress (j_compress_ptr cinfo, int version, size_t structsize)
* complain here.
*/
{
struct jpeg_error_mgr * err = cinfo->err;
void * client_data = cinfo->client_data; /* ignore Purify complaint here */
struct jpeg_error_mgr *err = cinfo->err;
void *client_data = cinfo->client_data; /* ignore Purify complaint here */
MEMZERO(cinfo, sizeof(struct jpeg_compress_struct));
cinfo->err = err;
cinfo->client_data = client_data;
Expand Down Expand Up @@ -134,8 +134,8 @@ GLOBAL(void)
jpeg_suppress_tables (j_compress_ptr cinfo, boolean suppress)
{
int i;
JQUANT_TBL * qtbl;
JHUFF_TBL * htbl;
JQUANT_TBL *qtbl;
JHUFF_TBL *htbl;

for (i = 0; i < NUM_QUANT_TBLS; i++) {
if ((qtbl = cinfo->quant_tbl_ptrs[i]) != NULL)
Expand Down
14 changes: 7 additions & 7 deletions jcarith.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ typedef struct {
int next_restart_num; /* next restart number to write (0-7) */

/* Pointers to statistics areas (these workspaces have image lifespan) */
unsigned char * dc_stats[NUM_ARITH_TBLS];
unsigned char * ac_stats[NUM_ARITH_TBLS];
unsigned char *dc_stats[NUM_ARITH_TBLS];
unsigned char *ac_stats[NUM_ARITH_TBLS];

/* Statistics bin for coding with fixed probability 0.5 */
unsigned char fixed_bin[4];
} arith_entropy_encoder;

typedef arith_entropy_encoder * arith_entropy_ptr;
typedef arith_entropy_encoder *arith_entropy_ptr;

/* The following two definitions specify the allocation chunk size
* for the statistics area.
Expand Down Expand Up @@ -119,7 +119,7 @@ LOCAL(void)
emit_byte (int val, j_compress_ptr cinfo)
/* Write next output byte; we do not support suspension in this module. */
{
struct jpeg_destination_mgr * dest = cinfo->dest;
struct jpeg_destination_mgr *dest = cinfo->dest;

*dest->next_output_byte++ = (JOCTET) val;
if (--dest->free_in_buffer == 0)
Expand Down Expand Up @@ -323,7 +323,7 @@ emit_restart (j_compress_ptr cinfo, int restart_num)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci;
jpeg_component_info * compptr;
jpeg_component_info *compptr;

finish_pass(cinfo);

Expand Down Expand Up @@ -683,7 +683,7 @@ METHODDEF(boolean)
encode_mcu (j_compress_ptr cinfo, JBLOCKROW *MCU_data)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
jpeg_component_info * compptr;
jpeg_component_info *compptr;
JBLOCKROW block;
unsigned char *st;
int blkn, ci, tbl, k, ke;
Expand Down Expand Up @@ -826,7 +826,7 @@ start_pass (j_compress_ptr cinfo, boolean gather_statistics)
{
arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
int ci, tbl;
jpeg_component_info * compptr;
jpeg_component_info *compptr;

if (gather_statistics)
/* Make sure to avoid that in the master control logic!
Expand Down
2 changes: 1 addition & 1 deletion jccoefct.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typedef struct {
jvirt_barray_ptr whole_image[MAX_COMPONENTS];
} my_coef_controller;

typedef my_coef_controller * my_coef_ptr;
typedef my_coef_controller *my_coef_ptr;


/* Forward declarations */
Expand Down
8 changes: 4 additions & 4 deletions jccolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ typedef struct {
struct jpeg_color_converter pub; /* public fields */

/* Private state for RGB->YCC conversion */
JLONG * rgb_ycc_tab; /* => table for RGB to YCbCr conversion */
JLONG *rgb_ycc_tab; /* => table for RGB to YCbCr conversion */
} my_color_converter;

typedef my_color_converter * my_cconvert_ptr;
typedef my_color_converter *my_cconvert_ptr;


/**************** RGB -> YCbCr conversion: most common case **************/
Expand Down Expand Up @@ -198,7 +198,7 @@ METHODDEF(void)
rgb_ycc_start (j_compress_ptr cinfo)
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
JLONG * rgb_ycc_tab;
JLONG *rgb_ycc_tab;
JLONG i;

/* Allocate and fill in the conversion tables. */
Expand Down Expand Up @@ -382,7 +382,7 @@ cmyk_ycck_convert (j_compress_ptr cinfo,
{
my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;
register int r, g, b;
register JLONG * ctab = cconvert->rgb_ycc_tab;
register JLONG *ctab = cconvert->rgb_ycc_tab;
register JSAMPROW inptr;
register JSAMPROW outptr0, outptr1, outptr2, outptr3;
register JDIMENSION col;
Expand Down
Loading

0 comments on commit bd49803

Please sign in to comment.