cvs: gd /libgd/src gd_tiff.c

[email protected] ("Pierre-Alain Joye") Fri, 05 Oct 2007 05:42:06 -0000
Newsgroups php.gd.cvs
Message-ID <cvspajoye1191562926@cvsserver>
pajoye		Fri Oct  5 05:42:06 2007 UTC

  Modified files:              
    /gd/libgd/src	gd_tiff.c 
  Log:
  - missing ;
  - add casting
  - fix logic in malloc test
  
  
http://cvs.php.net/viewvc.cgi/gd/libgd/src/gd_tiff.c?r1=1.6&r2=1.7&diff_format=u
Index: gd/libgd/src/gd_tiff.c
diff -u gd/libgd/src/gd_tiff.c:1.6 gd/libgd/src/gd_tiff.c:1.7
--- gd/libgd/src/gd_tiff.c:1.6	Thu Oct  4 22:01:15 2007
+++ gd/libgd/src/gd_tiff.c	Fri Oct  5 05:42:06 2007
@@ -20,14 +20,16 @@
    Todo:
 
    If we fail - cleanup
-   
+   Writer: Use gd error function, overflow check may not be necessary as
+	 we write our own data (check already done)
+
    (suggestions only)
    Implement 2 color black/white saving using group4 fax compression
    Implement function to specify encoding to use when writing tiff data
 
    ----------------------------------------------------------------------------
  */
-/* $Id: gd_tiff.c,v 1.6 2007/10/04 22:01:15 mattias Exp $ */
+/* $Id: gd_tiff.c,v 1.7 2007/10/05 05:42:06 pajoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 	#include "config.h"
@@ -68,7 +70,8 @@
 
 tiff_handle *new_tiff_handle(tiff_handle *t, gdIOCtx *g)
 {
-	if(!t || !g || (t = gdMalloc(sizeof(tiff_handle)))) {
+	t = (tiff_handle *) gdMalloc(sizeof(tiff_handle));
+	if(!t || !g) {
 		return 0;
 	}
 
@@ -247,9 +250,9 @@
 	/* build the color map for 8 bit images */
 	if(bitDepth != 24) {
 		/*TODO: Add checking */
-		colorMapRed = gdMalloc(3 * pow(2, bitsPerSample));
-		colorMapGreen = gdMalloc(3 * pow(2, bitsPerSample));
-		colorMapBlue = gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapRed = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapGreen = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
+		colorMapBlue = (uint16 *) gdMalloc(3 * pow(2, bitsPerSample));
 
 		for(i = 0; i < image->colorsTotal; i++) {
 			colorMapRed[i] = gdImageRed(image,i) + (gdImageRed(image,i) * 256);
@@ -277,11 +280,11 @@
 	TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, 1);
 
 	if(overflow2(width, samplesPerPixel)) {
-		return 0;
+		return;
 	}
 
-	if(!(scan = gdMalloc(width * samplesPerPixel))) {
-		return 0;
+	if(!(scan = (char *)gdMalloc(width * samplesPerPixel))) {
+		return;
 	}
 
 	/* loop through y-coords, and x-coords */
@@ -435,7 +438,7 @@
 BGD_DECLARE(gdImagePtr) createFromTiffCtx1bit(TIFF *tiff, int width, int height)
 {
 	gdImagePtr im = NULL;
-	int x, y,
+	int x, y;
 	int tileX, tileY, tileMaxX, tileMaxY;
 	int i, j, k;
 	int colour;
@@ -471,7 +474,7 @@
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		if(!(scan = gdMalloc(tileSize))) {
+		if(!(scan = (char *) gdMalloc(tileSize))) {
 			return 0;
 		}
 
@@ -534,7 +537,7 @@
 		/* image is not tiled - assume stripped (scanline) format */
 		printf("is a 1bit scanline tiff!\n");
 
-		if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
+		if(!(scan = (char *) gdMalloc(TIFFScanlineSize(tiff)))) {
 			return 0;
 		}
 
@@ -620,7 +623,7 @@
 		TIFFGetField(tiff, TIFFTAG_TILELENGTH, &tileMaxY);
 
 		tileSize = TIFFTileSize(tiff);
-		if(!(scan = gdMalloc(tileSize))) {
+		if(!(scan = (char*) gdMalloc(tileSize))) {
 			return 0;
 		}
 
@@ -672,7 +675,7 @@
 		gdFree(scan);
 
 	} else {
-		if(!(scan = gdMalloc(TIFFScanlineSize(tiff)))) {
+		if(!(scan = (char *)gdMalloc(TIFFScanlineSize(tiff)))) {
 			return 0;
 		}