52 lines
1.4 KiB
Text
52 lines
1.4 KiB
Text
$NetBSD: patch-af,v 1.1 2001/08/03 09:43:18 wiz Exp $
|
|
|
|
--- rw/readPNG.c.orig Thu Aug 29 07:24:48 1996
|
|
+++ rw/readPNG.c
|
|
@@ -46,8 +46,8 @@
|
|
ReadPNG(char *file)
|
|
{
|
|
FILE *fp;
|
|
- png_structp png_ptr;
|
|
- png_infop info_ptr;
|
|
+ png_structp png_ptr = NULL;
|
|
+ png_infop info_ptr = NULL;
|
|
int i, hasAlpha=FALSE;
|
|
int width, height, level, bit_depth, npasses;
|
|
Image *image = NULL;
|
|
@@ -59,14 +59,15 @@
|
|
return NULL;
|
|
}
|
|
|
|
- png_ptr = (png_structp)malloc(sizeof(png_struct));
|
|
+ png_ptr = (png_structp)png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
|
+ NULL, NULL, NULL);
|
|
if (!png_ptr) {
|
|
RWSetMsg("Error allocating PNG png_ptr memory");
|
|
fclose(fp);
|
|
return NULL;
|
|
}
|
|
|
|
- info_ptr = (png_infop)malloc(sizeof(png_info));
|
|
+ info_ptr = (png_infop)png_create_info_struct(png_ptr);
|
|
if (!info_ptr) {
|
|
RWSetMsg("Error allocating PNG info_ptr memory");
|
|
free(png_ptr);
|
|
@@ -74,17 +75,13 @@
|
|
return NULL;
|
|
}
|
|
|
|
- if (setjmp(png_ptr->jmpbuf)) {
|
|
+ if (setjmp(png_jmpbuf(png_ptr))) {
|
|
RWSetMsg("Error setting longjmp error handler");
|
|
png_read_destroy(png_ptr, info_ptr, (png_info *)0);
|
|
- free(png_ptr);
|
|
- free(info_ptr);
|
|
fclose(fp);
|
|
return NULL;
|
|
}
|
|
|
|
- png_info_init(info_ptr);
|
|
- png_read_init(png_ptr);
|
|
png_init_io(png_ptr, fp);
|
|
png_read_info(png_ptr, info_ptr);
|
|
|