Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(508)

Unified Diff: third_party/libpng/pngwio.c

Issue 2021403002: Update libpng to 1.6.22 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rearrange pnglibconf.h Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/libpng/pngvcrd.c ('k') | third_party/libpng/pngwrite.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/libpng/pngwio.c
diff --git a/third_party/libpng/pngwio.c b/third_party/libpng/pngwio.c
index 796224134ffb03ddd690793e8c6220d457623789..586c03b7218947ceeafc3ffb5a0fd0d4b04c217c 100644
--- a/third_party/libpng/pngwio.c
+++ b/third_party/libpng/pngwio.c
@@ -1,8 +1,8 @@
/* pngwio.c - functions for data output
*
- * Last changed in libpng 1.2.41 [December 3, 2009]
- * Copyright (c) 1998-2002,2004,2006-209 Glenn Randers-Pehrson
+ * Last changed in libpng 1.6.15 [November 20, 2014]
+ * Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
@@ -18,23 +18,25 @@
* them at run time with png_set_write_fn(...).
*/
-#define PNG_INTERNAL
-#define PNG_NO_PEDANTIC_WARNINGS
-#include "png.h"
+#include "pngpriv.h"
+
#ifdef PNG_WRITE_SUPPORTED
/* Write the data to whatever output you are using. The default routine
* writes to a file pointer. Note that this routine sometimes gets called
* with very small lengths, so you should implement some kind of simple
* buffering if you are using unbuffered writes. This should never be asked
- * to write more than 64K on a 16 bit machine.
+ * to write more than 64K on a 16-bit machine.
*/
void /* PRIVATE */
-png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
+png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
{
+ /* NOTE: write_data_fn must not change the buffer! */
if (png_ptr->write_data_fn != NULL )
- (*(png_ptr->write_data_fn))(png_ptr, data, length);
+ (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data),
+ length);
+
else
png_error(png_ptr, "Call to NULL write function");
}
@@ -45,85 +47,19 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
* write_data function and use it at run time with png_set_write_fn(), rather
* than changing the library.
*/
-#ifndef USE_FAR_KEYWORD
-void PNGAPI
-png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
- png_uint_32 check;
-
- if (png_ptr == NULL)
- return;
-#ifdef _WIN32_WCE
- if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
- check = 0;
-#else
- check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
-#endif
- if (check != length)
- png_error(png_ptr, "Write Error");
-}
-#else
-/* This is the model-independent version. Since the standard I/O library
- * can't handle far buffers in the medium and small models, we have to copy
- * the data.
- */
-
-#define NEAR_BUF_SIZE 1024
-#define MIN(a,b) (a <= b ? a : b)
-
-void PNGAPI
+void PNGCBAPI
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
{
- png_uint_32 check;
- png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */
- png_FILE_p io_ptr;
+ png_size_t check;
if (png_ptr == NULL)
return;
- /* Check if data really is near. If so, use usual code. */
- near_data = (png_byte *)CVT_PTR_NOCHECK(data);
- io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
- if ((png_bytep)near_data == data)
- {
-#ifdef _WIN32_WCE
- if ( !WriteFile(io_ptr, near_data, length, &check, NULL) )
- check = 0;
-#else
- check = fwrite(near_data, 1, length, io_ptr);
-#endif
- }
- else
- {
- png_byte buf[NEAR_BUF_SIZE];
- png_size_t written, remaining, err;
- check = 0;
- remaining = length;
- do
- {
- written = MIN(NEAR_BUF_SIZE, remaining);
- png_memcpy(buf, data, written); /* Copy far buffer to near buffer */
-#ifdef _WIN32_WCE
- if ( !WriteFile(io_ptr, buf, written, &err, NULL) )
- err = 0;
-#else
- err = fwrite(buf, 1, written, io_ptr);
-#endif
- if (err != written)
- break;
- else
- check += err;
+ check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
- data += written;
- remaining -= written;
- }
- while (remaining != 0);
- }
if (check != length)
png_error(png_ptr, "Write Error");
}
-
-#endif
#endif
/* This function is called to output any data pending writing (normally
@@ -132,27 +68,25 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
*/
#ifdef PNG_WRITE_FLUSH_SUPPORTED
void /* PRIVATE */
-png_flush(png_structp png_ptr)
+png_flush(png_structrp png_ptr)
{
if (png_ptr->output_flush_fn != NULL)
(*(png_ptr->output_flush_fn))(png_ptr);
}
-#ifdef PNG_STDIO_SUPPORTED
-void PNGAPI
+# ifdef PNG_STDIO_SUPPORTED
+void PNGCBAPI
png_default_flush(png_structp png_ptr)
{
-#ifndef _WIN32_WCE
png_FILE_p io_ptr;
-#endif
+
if (png_ptr == NULL)
return;
-#ifndef _WIN32_WCE
- io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr));
+
+ io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
fflush(io_ptr);
-#endif
}
-#endif
+# endif
#endif
/* This function allows the application to supply new output functions for
@@ -185,8 +119,8 @@ png_default_flush(png_structp png_ptr)
* *FILE structure.
*/
void PNGAPI
-png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
- png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
+png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
+ png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)
{
if (png_ptr == NULL)
return;
@@ -204,57 +138,31 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr,
#endif
#ifdef PNG_WRITE_FLUSH_SUPPORTED
-#ifdef PNG_STDIO_SUPPORTED
+# ifdef PNG_STDIO_SUPPORTED
+
if (output_flush_fn != NULL)
png_ptr->output_flush_fn = output_flush_fn;
else
png_ptr->output_flush_fn = png_default_flush;
-#else
+
+# else
png_ptr->output_flush_fn = output_flush_fn;
-#endif
-#endif /* PNG_WRITE_FLUSH_SUPPORTED */
+# endif
+#else
+ PNG_UNUSED(output_flush_fn)
+#endif /* WRITE_FLUSH */
+#ifdef PNG_READ_SUPPORTED
/* It is an error to read while writing a png file */
if (png_ptr->read_data_fn != NULL)
{
png_ptr->read_data_fn = NULL;
+
png_warning(png_ptr,
- "Attempted to set both read_data_fn and write_data_fn in");
- png_warning(png_ptr,
- "the same structure. Resetting read_data_fn to NULL.");
+ "Can't set both read_data_fn and write_data_fn in the"
+ " same structure");
}
+#endif
}
-
-#ifdef USE_FAR_KEYWORD
-#ifdef _MSC_VER
-void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
-{
- void *near_ptr;
- void FAR *far_ptr;
- FP_OFF(near_ptr) = FP_OFF(ptr);
- far_ptr = (void FAR *)near_ptr;
-
- if (check != 0)
- if (FP_SEG(ptr) != FP_SEG(far_ptr))
- png_error(png_ptr, "segment lost in conversion");
-
- return(near_ptr);
-}
-# else
-void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check)
-{
- void *near_ptr;
- void FAR *far_ptr;
- near_ptr = (void FAR *)ptr;
- far_ptr = (void FAR *)near_ptr;
-
- if (check != 0)
- if (far_ptr != ptr)
- png_error(png_ptr, "segment lost in conversion");
-
- return(near_ptr);
-}
-# endif
-# endif
-#endif /* PNG_WRITE_SUPPORTED */
+#endif /* WRITE */
« no previous file with comments | « third_party/libpng/pngvcrd.c ('k') | third_party/libpng/pngwrite.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698