summaryrefslogtreecommitdiff
path: root/pngerror.c
diff options
context:
space:
mode:
authorJohn Bowler <jbowler@acm.org>2011-11-16 16:39:16 -0600
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2011-11-16 16:39:16 -0600
commit4fa96a42f752bd70958eaf2635de7e0a875f13a2 (patch)
treed55d23c534d5811f9702c1bc6df5c90c71399ff0 /pngerror.c
parentc2d8399581bc3b2b87172e223835cbfd1fd2555e (diff)
downloadlibpng-4fa96a42f752bd70958eaf2635de7e0a875f13a2.tar.gz
[libpng15] Fixes for C++ compilation using g++ When libpng source is compiled
using g++. The compiler imposes C++ rules on the C source; thus it is desireable to make the source work with either C or C++ rules without throwing away useful error information. This change adds png_voidcast to allow C semantic (void*) cases or the corresponding C++ static_cast operation, as appropriate.
Diffstat (limited to 'pngerror.c')
-rw-r--r--pngerror.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/pngerror.c b/pngerror.c
index 74f8cc845..d09bcba24 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -684,7 +684,7 @@ PNG_FUNCTION(void /* PRIVATE */,
png_safe_error,(png_structp png_ptr, png_const_charp error_message),
PNG_NORETURN)
{
- png_imagep image = png_ptr->error_ptr;
+ png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
/* An error is always logged here, overwriting anything (typically a warning)
* that is already there:
@@ -694,9 +694,12 @@ png_safe_error,(png_structp png_ptr, png_const_charp error_message),
png_safecat(image->message, sizeof image->message, 0, error_message);
image->warning_or_error = 1;
- /* Retrieve the jmp_buf from within the png_control */
+ /* Retrieve the jmp_buf from within the png_control, making this work for
+ * C++ compilation too is pretty tricky: C++ wants a pointer to the first
+ * element of a jmp_buf, but C doesn't tell us the type of that.
+ */
if (image->opaque != NULL && image->opaque->error_buf != NULL)
- longjmp(image->opaque->error_buf, 1);
+ longjmp(png_control_jmp_buf(image->opaque), 1);
/* Missing longjmp buffer, the following is to help debugging: */
{
@@ -714,7 +717,7 @@ png_safe_error,(png_structp png_ptr, png_const_charp error_message),
void /* PRIVATE */
png_safe_warning(png_structp png_ptr, png_const_charp warning_message)
{
- png_imagep image = png_ptr->error_ptr;
+ png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
/* A warning is only logged if there is no prior warning or error. */
if (image->warning_or_error == 0)