| Index: jdatadst.c
|
| diff --git a/jdatadst.c b/jdatadst.c
|
| index 1b89fabeaa75875bad38e92c8f62e28f09e8c017..21018b0f1b351a8cc9b679cd5bf76dcd69523155 100644
|
| --- a/jdatadst.c
|
| +++ b/jdatadst.c
|
| @@ -6,7 +6,8 @@
|
| * Modified 2009-2012 by Guido Vollbeding.
|
| * libjpeg-turbo Modifications:
|
| * Copyright (C) 2013, D. R. Commander.
|
| - * For conditions of distribution and use, see the accompanying README file.
|
| + * For conditions of distribution and use, see the accompanying README.ijg
|
| + * file.
|
| *
|
| * This file contains compression data destination routines for the case of
|
| * emitting JPEG data to memory or to a file (or any stdio stream).
|
| @@ -22,9 +23,9 @@
|
| #include "jpeglib.h"
|
| #include "jerror.h"
|
|
|
| -#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
| -extern void * malloc JPP((size_t size));
|
| -extern void free JPP((void *ptr));
|
| +#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
| +extern void *malloc (size_t size);
|
| +extern void free (void *ptr);
|
| #endif
|
|
|
|
|
| @@ -33,13 +34,13 @@ extern void free JPP((void *ptr));
|
| typedef struct {
|
| struct jpeg_destination_mgr pub; /* public fields */
|
|
|
| - FILE * outfile; /* target stream */
|
| - JOCTET * buffer; /* start of buffer */
|
| + FILE *outfile; /* target stream */
|
| + JOCTET *buffer; /* start of buffer */
|
| } my_destination_mgr;
|
|
|
| -typedef my_destination_mgr * my_dest_ptr;
|
| +typedef my_destination_mgr *my_dest_ptr;
|
|
|
| -#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
| +#define OUTPUT_BUF_SIZE 4096 /* choose an efficiently fwrite'able size */
|
|
|
|
|
| #if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)
|
| @@ -48,14 +49,14 @@ typedef my_destination_mgr * my_dest_ptr;
|
| typedef struct {
|
| struct jpeg_destination_mgr pub; /* public fields */
|
|
|
| - unsigned char ** outbuffer; /* target buffer */
|
| - unsigned long * outsize;
|
| - unsigned char * newbuffer; /* newly allocated buffer */
|
| - JOCTET * buffer; /* start of buffer */
|
| + unsigned char **outbuffer; /* target buffer */
|
| + unsigned long *outsize;
|
| + unsigned char *newbuffer; /* newly allocated buffer */
|
| + JOCTET *buffer; /* start of buffer */
|
| size_t bufsize;
|
| } my_mem_destination_mgr;
|
|
|
| -typedef my_mem_destination_mgr * my_mem_dest_ptr;
|
| +typedef my_mem_destination_mgr *my_mem_dest_ptr;
|
| #endif
|
|
|
|
|
| @@ -72,7 +73,7 @@ init_destination (j_compress_ptr cinfo)
|
| /* Allocate the output buffer --- it will be released when done with image */
|
| dest->buffer = (JOCTET *)
|
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
|
| - OUTPUT_BUF_SIZE * SIZEOF(JOCTET));
|
| + OUTPUT_BUF_SIZE * sizeof(JOCTET));
|
|
|
| dest->pub.next_output_byte = dest->buffer;
|
| dest->pub.free_in_buffer = OUTPUT_BUF_SIZE;
|
| @@ -130,7 +131,7 @@ METHODDEF(boolean)
|
| empty_mem_output_buffer (j_compress_ptr cinfo)
|
| {
|
| size_t nextsize;
|
| - JOCTET * nextbuffer;
|
| + JOCTET *nextbuffer;
|
| my_mem_dest_ptr dest = (my_mem_dest_ptr) cinfo->dest;
|
|
|
| /* Try to allocate new buffer with double size */
|
| @@ -203,7 +204,7 @@ term_mem_destination (j_compress_ptr cinfo)
|
| */
|
|
|
| GLOBAL(void)
|
| -jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
| +jpeg_stdio_dest (j_compress_ptr cinfo, FILE *outfile)
|
| {
|
| my_dest_ptr dest;
|
|
|
| @@ -213,10 +214,10 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
| * manager serially with the same JPEG object, because their private object
|
| * sizes may be different. Caveat programmer.
|
| */
|
| - if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
| + if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
| cinfo->dest = (struct jpeg_destination_mgr *)
|
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
| - SIZEOF(my_destination_mgr));
|
| + sizeof(my_destination_mgr));
|
| }
|
|
|
| dest = (my_dest_ptr) cinfo->dest;
|
| @@ -237,24 +238,27 @@ jpeg_stdio_dest (j_compress_ptr cinfo, FILE * outfile)
|
| * larger memory, so the buffer is available to the application after
|
| * finishing compression, and then the application is responsible for
|
| * freeing the requested memory.
|
| + * Note: An initial buffer supplied by the caller is expected to be
|
| + * managed by the application. The library does not free such buffer
|
| + * when allocating a larger buffer.
|
| */
|
|
|
| GLOBAL(void)
|
| jpeg_mem_dest (j_compress_ptr cinfo,
|
| - unsigned char ** outbuffer, unsigned long * outsize)
|
| + unsigned char **outbuffer, unsigned long *outsize)
|
| {
|
| my_mem_dest_ptr dest;
|
|
|
| - if (outbuffer == NULL || outsize == NULL) /* sanity check */
|
| + if (outbuffer == NULL || outsize == NULL) /* sanity check */
|
| ERREXIT(cinfo, JERR_BUFFER_SIZE);
|
|
|
| /* The destination object is made permanent so that multiple JPEG images
|
| * can be written to the same buffer without re-executing jpeg_mem_dest.
|
| */
|
| - if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
| + if (cinfo->dest == NULL) { /* first time for this JPEG object? */
|
| cinfo->dest = (struct jpeg_destination_mgr *)
|
| (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
|
| - SIZEOF(my_mem_destination_mgr));
|
| + sizeof(my_mem_destination_mgr));
|
| }
|
|
|
| dest = (my_mem_dest_ptr) cinfo->dest;
|
|
|