| Index: wrtarga.c
 | 
| diff --git a/wrtarga.c b/wrtarga.c
 | 
| index cf104d2debd0ffbbfc67bbe00b332dc8ad77980d..c02b3321981db349eee20dc38ebcdbee0aec8a89 100644
 | 
| --- a/wrtarga.c
 | 
| +++ b/wrtarga.c
 | 
| @@ -1,9 +1,12 @@
 | 
|  /*
 | 
|   * wrtarga.c
 | 
|   *
 | 
| + * This file was part of the Independent JPEG Group's software:
 | 
|   * Copyright (C) 1991-1996, Thomas G. Lane.
 | 
| - * This file is part of the Independent JPEG Group's software.
 | 
| - * For conditions of distribution and use, see the accompanying README file.
 | 
| + * It was modified by The libjpeg-turbo Project to include only code and
 | 
| + * information relevant to libjpeg-turbo.
 | 
| + * For conditions of distribution and use, see the accompanying README.ijg
 | 
| + * file.
 | 
|   *
 | 
|   * This file contains routines to write output images in Targa format.
 | 
|   *
 | 
| @@ -14,7 +17,7 @@
 | 
|   * Based on code contributed by Lee Daniel Crocker.
 | 
|   */
 | 
|  
 | 
| -#include "cdjpeg.h"		/* Common decls for cjpeg/djpeg applications */
 | 
| +#include "cdjpeg.h"             /* Common decls for cjpeg/djpeg applications */
 | 
|  
 | 
|  #ifdef TARGA_SUPPORTED
 | 
|  
 | 
| @@ -28,26 +31,17 @@
 | 
|    Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
 | 
|  #endif
 | 
|  
 | 
| -/*
 | 
| - * The output buffer needs to be writable by fwrite().  On PCs, we must
 | 
| - * allocate the buffer in near data space, because we are assuming small-data
 | 
| - * memory model, wherein fwrite() can't reach far memory.  If you need to
 | 
| - * process very wide images on a PC, you might have to compile in large-memory
 | 
| - * model, or else replace fwrite() with a putc() loop --- which will be much
 | 
| - * slower.
 | 
| - */
 | 
| -
 | 
|  
 | 
|  /* Private version of data destination object */
 | 
|  
 | 
|  typedef struct {
 | 
| -  struct djpeg_dest_struct pub;	/* public fields */
 | 
| +  struct djpeg_dest_struct pub; /* public fields */
 | 
|  
 | 
| -  char *iobuffer;		/* physical I/O buffer */
 | 
| -  JDIMENSION buffer_width;	/* width of one row */
 | 
| +  char *iobuffer;               /* physical I/O buffer */
 | 
| +  JDIMENSION buffer_width;      /* width of one row */
 | 
|  } tga_dest_struct;
 | 
|  
 | 
| -typedef tga_dest_struct * tga_dest_ptr;
 | 
| +typedef tga_dest_struct *tga_dest_ptr;
 | 
|  
 | 
|  
 | 
|  LOCAL(void)
 | 
| @@ -57,30 +51,30 @@ write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
 | 
|    char targaheader[18];
 | 
|  
 | 
|    /* Set unused fields of header to 0 */
 | 
| -  MEMZERO(targaheader, SIZEOF(targaheader));
 | 
| +  MEMZERO(targaheader, sizeof(targaheader));
 | 
|  
 | 
|    if (num_colors > 0) {
 | 
| -    targaheader[1] = 1;		/* color map type 1 */
 | 
| +    targaheader[1] = 1;         /* color map type 1 */
 | 
|      targaheader[5] = (char) (num_colors & 0xFF);
 | 
|      targaheader[6] = (char) (num_colors >> 8);
 | 
| -    targaheader[7] = 24;	/* 24 bits per cmap entry */
 | 
| +    targaheader[7] = 24;        /* 24 bits per cmap entry */
 | 
|    }
 | 
|  
 | 
|    targaheader[12] = (char) (cinfo->output_width & 0xFF);
 | 
|    targaheader[13] = (char) (cinfo->output_width >> 8);
 | 
|    targaheader[14] = (char) (cinfo->output_height & 0xFF);
 | 
|    targaheader[15] = (char) (cinfo->output_height >> 8);
 | 
| -  targaheader[17] = 0x20;	/* Top-down, non-interlaced */
 | 
| +  targaheader[17] = 0x20;       /* Top-down, non-interlaced */
 | 
|  
 | 
|    if (cinfo->out_color_space == JCS_GRAYSCALE) {
 | 
| -    targaheader[2] = 3;		/* image type = uncompressed gray-scale */
 | 
| -    targaheader[16] = 8;	/* bits per pixel */
 | 
| -  } else {			/* must be RGB */
 | 
| +    targaheader[2] = 3;         /* image type = uncompressed grayscale */
 | 
| +    targaheader[16] = 8;        /* bits per pixel */
 | 
| +  } else {                      /* must be RGB */
 | 
|      if (num_colors > 0) {
 | 
| -      targaheader[2] = 1;	/* image type = colormapped RGB */
 | 
| +      targaheader[2] = 1;       /* image type = colormapped RGB */
 | 
|        targaheader[16] = 8;
 | 
|      } else {
 | 
| -      targaheader[2] = 2;	/* image type = uncompressed RGB */
 | 
| +      targaheader[2] = 2;       /* image type = uncompressed RGB */
 | 
|        targaheader[16] = 24;
 | 
|      }
 | 
|    }
 | 
| @@ -97,12 +91,12 @@ write_header (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo, int num_colors)
 | 
|  
 | 
|  METHODDEF(void)
 | 
|  put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
 | 
| -		JDIMENSION rows_supplied)
 | 
| +                JDIMENSION rows_supplied)
 | 
|  /* used for unquantized full-color output */
 | 
|  {
 | 
|    tga_dest_ptr dest = (tga_dest_ptr) dinfo;
 | 
|    register JSAMPROW inptr;
 | 
| -  register char * outptr;
 | 
| +  register char *outptr;
 | 
|    register JDIMENSION col;
 | 
|  
 | 
|    inptr = dest->pub.buffer[0];
 | 
| @@ -118,12 +112,12 @@ put_pixel_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
 | 
|  
 | 
|  METHODDEF(void)
 | 
|  put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
 | 
| -	       JDIMENSION rows_supplied)
 | 
| +               JDIMENSION rows_supplied)
 | 
|  /* used for grayscale OR quantized color output */
 | 
|  {
 | 
|    tga_dest_ptr dest = (tga_dest_ptr) dinfo;
 | 
|    register JSAMPROW inptr;
 | 
| -  register char * outptr;
 | 
| +  register char *outptr;
 | 
|    register JDIMENSION col;
 | 
|  
 | 
|    inptr = dest->pub.buffer[0];
 | 
| @@ -142,11 +136,11 @@ put_gray_rows (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
 | 
|  
 | 
|  METHODDEF(void)
 | 
|  put_demapped_gray (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo,
 | 
| -		   JDIMENSION rows_supplied)
 | 
| +                   JDIMENSION rows_supplied)
 | 
|  {
 | 
|    tga_dest_ptr dest = (tga_dest_ptr) dinfo;
 | 
|    register JSAMPROW inptr;
 | 
| -  register char * outptr;
 | 
| +  register char *outptr;
 | 
|    register JSAMPROW color_map0 = cinfo->colormap[0];
 | 
|    register JDIMENSION col;
 | 
|  
 | 
| @@ -183,14 +177,14 @@ start_output_tga (j_decompress_ptr cinfo, djpeg_dest_ptr dinfo)
 | 
|        /* We only support 8-bit colormap indexes, so only 256 colors */
 | 
|        num_colors = cinfo->actual_number_of_colors;
 | 
|        if (num_colors > 256)
 | 
| -	ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors);
 | 
| +        ERREXIT1(cinfo, JERR_TOO_MANY_COLORS, num_colors);
 | 
|        write_header(cinfo, dinfo, num_colors);
 | 
|        /* Write the colormap.  Note Targa uses BGR byte order */
 | 
|        outfile = dest->pub.output_file;
 | 
|        for (i = 0; i < num_colors; i++) {
 | 
| -	putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile);
 | 
| -	putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile);
 | 
| -	putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile);
 | 
| +        putc(GETJSAMPLE(cinfo->colormap[2][i]), outfile);
 | 
| +        putc(GETJSAMPLE(cinfo->colormap[1][i]), outfile);
 | 
| +        putc(GETJSAMPLE(cinfo->colormap[0][i]), outfile);
 | 
|        }
 | 
|        dest->pub.put_pixel_rows = put_gray_rows;
 | 
|      } else {
 | 
| @@ -229,18 +223,18 @@ jinit_write_targa (j_decompress_ptr cinfo)
 | 
|    /* Create module interface object, fill in method pointers */
 | 
|    dest = (tga_dest_ptr)
 | 
|        (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
 | 
| -				  SIZEOF(tga_dest_struct));
 | 
| +                                  sizeof(tga_dest_struct));
 | 
|    dest->pub.start_output = start_output_tga;
 | 
|    dest->pub.finish_output = finish_output_tga;
 | 
|  
 | 
|    /* Calculate output image dimensions so we can allocate space */
 | 
|    jpeg_calc_output_dimensions(cinfo);
 | 
|  
 | 
| -  /* Create I/O buffer.  Note we make this near on a PC. */
 | 
| +  /* Create I/O buffer. */
 | 
|    dest->buffer_width = cinfo->output_width * cinfo->output_components;
 | 
|    dest->iobuffer = (char *)
 | 
|      (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
 | 
| -				(size_t) (dest->buffer_width * SIZEOF(char)));
 | 
| +                                (size_t) (dest->buffer_width * sizeof(char)));
 | 
|  
 | 
|    /* Create decompressor output buffer. */
 | 
|    dest->pub.buffer = (*cinfo->mem->alloc_sarray)
 | 
| 
 |